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 79748af2b2344e9e
parent 7973 5d12bfc720e1
child 7975 1b49b680f319
Updated androidbuild.sh to enable parallel builds and ndk-build parameters
build-scripts/androidbuild.sh
     1.1 --- a/build-scripts/androidbuild.sh	Tue Nov 12 11:31:13 2013 -0300
     1.2 +++ b/build-scripts/androidbuild.sh	Wed Nov 13 09:41:21 2013 -0300
     1.3 @@ -25,6 +25,7 @@
     1.4      echo "Usage: androidbuild.sh com.yourcompany.yourapp < sources.list"
     1.5      echo "Usage: androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c"
     1.6      echo "To copy SDL source instead of symlinking: COPYSOURCE=1 androidbuild.sh ... "
     1.7 +    echo "You can pass additional arguments to ndk-build with the NDKARGS variable: NDKARGS=\"-s\" androidbuild.sh ..."
     1.8      exit 1
     1.9  fi
    1.10  
    1.11 @@ -51,6 +52,19 @@
    1.12      exit 1
    1.13  fi
    1.14  
    1.15 +NCPUS="1"
    1.16 +case "$OSTYPE" in
    1.17 +    darwin*)
    1.18 +        NCPU=`sysctl -n hw.ncpu`
    1.19 +        ;; 
    1.20 +    linux*)
    1.21 +        if [ -n `which nproc` ]; then
    1.22 +            NCPUS=`nproc`
    1.23 +        fi  
    1.24 +        ;;
    1.25 +  *);;
    1.26 +esac
    1.27 +
    1.28  APP="$1"
    1.29  APPARR=(${APP//./ })
    1.30  BUILDPATH="$SDLPATH/build/$APP"
    1.31 @@ -102,7 +116,7 @@
    1.32  # Update project and build
    1.33  cd $BUILDPATH
    1.34  android update project --path $BUILDPATH
    1.35 -$NDKBUILD
    1.36 +$NDKBUILD -j $NCPUS $NDKARGS
    1.37  $ANT debug
    1.38  
    1.39  cd $CURDIR