build-scripts/androidbuildlibs.sh
changeset 11262 8e5441ab6c63
child 11836 a42b155124a3
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/build-scripts/androidbuildlibs.sh	Sun Aug 13 17:59:59 2017 -0700
     1.3 @@ -0,0 +1,74 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# Build the Android libraries without needing a project
     1.7 +# (AndroidManifest.xml, jni/{Application,Android}.mk, etc.)
     1.8 +#
     1.9 +# Usage: androidbuildlibs.sh [arg for ndk-build ...]"
    1.10 +#
    1.11 +# Useful NDK arguments:
    1.12 +#
    1.13 +#  NDK_DEBUG=1          - build debug version
    1.14 +#  NDK_LIBS_OUT=<dest>  - specify alternate destination for installable
    1.15 +#                         modules.
    1.16 +#
    1.17 +# Note that SDLmain is not an installable module (.so) so libSDLmain.a
    1.18 +# can be found in $obj/local/<abi> along with the unstripped libSDL.so.
    1.19 +#
    1.20 +
    1.21 +
    1.22 +# Android.mk is in srcdir
    1.23 +srcdir=`dirname $0`/..
    1.24 +srcdir=`cd $srcdir && pwd`
    1.25 +cd $srcdir
    1.26 +
    1.27 +
    1.28 +#
    1.29 +# Create the build directories
    1.30 +#
    1.31 +
    1.32 +build=build
    1.33 +buildandroid=$build/android
    1.34 +obj=
    1.35 +lib=
    1.36 +ndk_args=
    1.37 +
    1.38 +# Allow an external caller to specify locations.
    1.39 +for arg in $*
    1.40 +do
    1.41 +  if [ "${arg:0:8}" == "NDK_OUT=" ]; then
    1.42 +	obj=${arg#NDK_OUT=}
    1.43 +  elif [ "${arg:0:13}" == "NDK_LIBS_OUT=" ]; then
    1.44 +	lib=${arg#NDK_LIBS_OUT=}
    1.45 +  else
    1.46 +    ndk_args="$ndk_args $arg"
    1.47 +  fi
    1.48 +done
    1.49 +
    1.50 +if [ -z $obj ]; then
    1.51 +  obj=$buildandroid/obj
    1.52 +fi
    1.53 +if [ -z $lib ]; then
    1.54 +  lib=$buildandroid/lib
    1.55 +fi
    1.56 +
    1.57 +for dir in $build $buildandroid $obj $lib; do
    1.58 +    if test -d $dir; then
    1.59 +        :
    1.60 +    else
    1.61 +        mkdir $dir || exit 1
    1.62 +    fi
    1.63 +done
    1.64 +
    1.65 +
    1.66 +# APP_* variables set in the environment here will not be seen by the
    1.67 +# ndk-build makefile segments that use them, e.g., default-application.mk.
    1.68 +# For consistency, pass all values on the command line.
    1.69 +ndk-build \
    1.70 +  NDK_PROJECT_PATH=null \
    1.71 +  NDK_OUT=$obj \
    1.72 +  NDK_LIBS_OUT=$lib \
    1.73 +  APP_BUILD_SCRIPT=Android.mk \
    1.74 +  APP_ABI="all" \
    1.75 +  APP_PLATFORM=android-12 \
    1.76 +  APP_MODULES="SDL2 SDL2_main" \
    1.77 +  $ndk_args