* .bat Files opened from Eclipse open in the wrong directory

I'm completely new to scripting, but I'm tired of compiling my own Android code manually, so I wrote a little .sh script and a .bat file to run this script in cygwin. Both files are placed in the root of the project, the NDK directory is installed in the .sh file, and then, by running the .bat file, I will compile my own code.

The problem is that I want to do this dynamically, so I use% CD% to get the current directory (which should be the project folder) and run the .sh file in that directory.

Here are both files:

.bat:

@echo off

::Used to surpess a warning about dos directory format.
set CYGWIN=nodosfilewarning

C:\cygwin\bin\bash --login -i %CD%\./compile.sh

pause

.sh:

#!/bin/bash

#Run this script through compileNative.bat This will compile the native code of this Project
#IF this file is changed under windows use "tr -d '\r' < edited.sh > final.sh " to remove the bad line endings.
#Keep both this and the .bat file in the project root.
# Set this to the base NDKDir
NDKDIR=C:/Android/NDK/


#Get the base dir so we can change the directory to the base dir.
BASEDIR=`dirname $0`

echo 
echo Compiling Native code. Refresh Workspace after this is done!
echo 
#Change to the directory of the project, change this is if the project movies.
cd $BASEDIR

#Run the ndk build file. Change this to the correct location.
$NDKDIR./ndk-build

.bat , . , , % CD% "C:/Eclipse". , , .

, : % CD% . , . , .

.

+3
2

( " " "/" ). .

(, ), , ${container_loc} ${resource_loc} - Variables..., .

: cygwin script , bat.

0

:

%~d0
cd %~p0

, % 0;

, % 0.

+7

Source: https://habr.com/ru/post/1757988/


All Articles