Pan*_*oro 3 eclipse shell batch-file
我完全不熟悉脚本,但我厌倦了手动编译Android的本机代码,所以我写了一个.sh脚本和一个.bat文件来运行cygwin中的这个脚本.两个文件都放在项目的根目录中,在.sh文件中设置了NDK目录,然后通过运行.bat文件编译我的本机代码.
问题是我想动态地这样做,所以我使用%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
Run Code Online (Sandbox Code Playgroud)
.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
Run Code Online (Sandbox Code Playgroud)
当我从Windows中的文件夹中打开.bat文件时,它运行得很好.当我从eclipse运行它虽然似乎%CD%给了我"C:/ Eclipse".更让我烦恼的是它整个早上都跑了,但突然之间就开始这么做了.
所以我的问题是,我是以错误的方式使用%CD%,还是为什么会发生这种情况.显然这不是一个大戏.但这是一个令人讨厌的问题,我似乎无法弄明白.
一些帮助会很棒.
小智 7
在批处理文件的顶部插入这些命令:
%~d0
cd %~p0
Run Code Online (Sandbox Code Playgroud)
第一个命令将当前驱动器更改为从%0参数中提取的驱动器;
第二个将当前dir更改为从%0参数中提取的路径.
| 归档时间: |
|
| 查看次数: |
1684 次 |
| 最近记录: |