我是一个全新的脚本编写者,但我已经厌倦了手动为Android编译我的本地代码,所以我编写了一个小的.sh脚本和一个.bat文件,在cygwin中运行此脚本。这两个文件都放置在项目的根目录下,.sh文件中设置了NDK目录,然后通过运行.bat文件来编译我的本地代码。
问题在于我想要动态执行它,所以我使用%CD%获取当前目录(应该是项目文件夹),并在该目录中启动.sh文件。
以下是两个文件:
.bat 文件:
当我在Windows中从文件夹打开.bat文件时,它可以正常运行。但是当我从Eclipse中运行它时,似乎%CD%会给出"C:/Eclipse"。更让我烦恼的是,它早上一直可以运行,但突然间就出现了这个问题。
所以我的问题是,我是否使用了错误的%CD%方式,或者为什么会发生这种情况。显然这不是一个大问题。但这是一个我似乎无法解决的小烦恼。
希望能得到一些帮助。
问题在于我想要动态执行它,所以我使用%CD%获取当前目录(应该是项目文件夹),并在该目录中启动.sh文件。
以下是两个文件:
.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
当我在Windows中从文件夹打开.bat文件时,它可以正常运行。但是当我从Eclipse中运行它时,似乎%CD%会给出"C:/Eclipse"。更让我烦恼的是,它早上一直可以运行,但突然间就出现了这个问题。
所以我的问题是,我是否使用了错误的%CD%方式,或者为什么会发生这种情况。显然这不是一个大问题。但这是一个我似乎无法解决的小烦恼。
希望能得到一些帮助。