I'm trying to make a simple build script that would work on windows and unix systems. The script is to be run from cygwin if windows, otherwise just a standard shell.
The script will do the following:
I'm not sure what kind of scripting language to use nor its syntax, I only know it would roughly look like above. Any ideas on how to proceed?
It seems to me that you already wrote the script, it just needs a few modifications:
Windows myscript.cmd
@ECHO OFF
setlocal
SET SDK_ROOT=C:\PROGRA~2\Android\android-sdk\
SET NDK_ROOT=C:\PROGRA~2\android-ndk-r6b\
CD Android/bin/
javah -d ../../test/mytest/ -classpath .:%SDK_ROOT%/platforms/android-8/android.jar com.test.MyTest
CD ..
RUN %NDK_ROOT%/ndk-build
endlocal
Unixmyscript.sh
#!/bin/bash
SDK_ROOT="/cygdrive/C/PROGRA~2/Android/android-sdk/"
NDK_ROOT="/cygdrive/C/PROGRA~2/android-ndk-r6b"
cd Android/bin/
javah -d ../../test/mytest/ -classpath .:${SDK_ROOT}/platforms/android-8/android.jar com.test.MyTest
cd ..
$NDK_ROOT/ndk-build
Also, make sure that javah exists in your PATH env variable.
if it doesn't exist, you can add it to the scripts at the beginning:
Windows SET PATH=c:\path\to\javah;%PATH%
Unixexport PATH=/path/to/javah:$PATH
Note: you might have to modify the sdk/ndk paths for the script on windows.
If you're using Eclipse, I would suggest creating a new launcher for this task. Open up your project properties, and select Builders from the left pane. We want to end up with this:
Click "New..." and create a new program launcher:
Fill in the path to ndk-build
(I would suggest adding it to your system path so that you don't need an absolute path as depicted) and the project workspace:
This should already work, but we can restrict which resources are refreshed upon completion:
libs
folder in your project and select it (and any additional folders affected by the ndk-build
, if applicable)Finally, we can restrict when NDK Builder should run (namely only when the JNI source changes):
jni
folder in your project and select it (or wherever you have the JNI source files, plus any additional files that should trigger a new ndk-build
)I hope this makes your build process easier!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With