Updated androidbuild.sh to enable parallel builds and ndk-build parameters
authorGabriel Jacobo <gabomdq@gmail.com>
Wed, 13 Nov 2013 09:41:21 -0300
changeset 7974 8af2b2344e9e
parent 7973 5d12bfc720e1
child 7975 1b49b680f319
Updated androidbuild.sh to enable parallel builds and ndk-build parameters
build-scripts/androidbuild.sh
--- a/build-scripts/androidbuild.sh	Tue Nov 12 11:31:13 2013 -0300
+++ b/build-scripts/androidbuild.sh	Wed Nov 13 09:41:21 2013 -0300
@@ -25,6 +25,7 @@
     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 @@
     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 @@
 # Update project and build
 cd $BUILDPATH
 android update project --path $BUILDPATH
-$NDKBUILD
+$NDKBUILD -j $NCPUS $NDKARGS
 $ANT debug
 
 cd $CURDIR