我完全不熟悉脚本,但是我厌倦了手动编译Android本机代码,所以我写了一个.sh脚本和一个.bat文件在cygwin中运行这个脚本。 这两个文件都放在项目的根目录中,在.sh文件中设置了NDK目录,然后运行.bat文件编译我的本机代码。* .bat从Eclipse打开的文件在错误的目录中打开
问题是我想动态地这样做,所以我使用%CD%来获取当前目录(应该是项目文件夹)并在该目录中启动.sh文件。
这里有两个文件:
蝙蝠:
@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文件运行就好了。当我从eclipse运行它时,虽然看起来%CD%给了我“C:/ Eclipse”。让我更加恼火的是它整个早晨都在运行,但突然间它开始这样做。
所以我的问题是,我是否以错误的方式使用%CD%或为什么会发生这种情况。显然这不是一个大戏。但这是一个令人讨厌的问题,我似乎无法弄清楚。
一些帮助会很好。
今天我终于来测试你的建议。它像一个魅力,现在它甚至不打开一个新窗口,但我可以在Eclipse控制台中看到它。 我确实保留了bat文件,因为我不想在这上面花太多时间。但我想你是对的,没有bat文件也是可以的。 非常感谢! – Pandoro 2010-08-06 11:35:04