Updated androidbuild.sh to enable parallel builds and ndk-build parameters
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
diff --git a/build-scripts/androidbuild.sh b/build-scripts/androidbuild.sh
index eed0622..ea6e6b1 100755
--- a/build-scripts/androidbuild.sh
+++ b/build-scripts/androidbuild.sh
@@ -25,6 +25,7 @@ if [ -z "$1" ] || [ -z "$SOURCES" ]; then
echo "Usage: androidbuild.sh com.yourcompany.yourapp < sources.list"
echo "Usage: androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c"
echo "To copy SDL source instead of symlinking: COPYSOURCE=1 androidbuild.sh ... "
+ echo "You can pass additional arguments to ndk-build with the NDKARGS variable: NDKARGS=\"-s\" androidbuild.sh ..."
exit 1
fi
@@ -51,6 +52,19 @@ if [ -z "$ANT" ];then
exit 1
fi
+NCPUS="1"
+case "$OSTYPE" in
+ darwin*)
+ NCPU=`sysctl -n hw.ncpu`
+ ;;
+ linux*)
+ if [ -n `which nproc` ]; then
+ NCPUS=`nproc`
+ fi
+ ;;
+ *);;
+esac
+
APP="$1"
APPARR=(${APP//./ })
BUILDPATH="$SDLPATH/build/$APP"
@@ -102,7 +116,7 @@ echo "public class $ACTIVITY extends SDLActivity {}" >> "$ACTIVITY.java"
# Update project and build
cd $BUILDPATH
android update project --path $BUILDPATH
-$NDKBUILD
+$NDKBUILD -j $NCPUS $NDKARGS
$ANT debug
cd $CURDIR