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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
#!/bin/bash
# Usage: androidbuild.sh [arg for ndk-build ...]
#
# Useful NDK arguments:
#
# NDK_DEBUG=1 - build debug version
# NDK_LIBS_OUT=<dest> - specify alternate destination for installable
# modules.
srcdir=`dirname $0`/../src
srcdir=`cd $srcdir && pwd`
cd $srcdir
#
# Create the build directories
#
build=build
buildandroid=$build/android
platform=android-16
abi="arm64-v8a" # "armeabi-v7a arm64-v8a x86 x86_64"
obj=
lib=
ndk_args=
# Allow an external caller to specify locations and platform.
while [ $# -gt 0 ]; do
arg=$1
if [ "${arg:0:8}" == "NDK_OUT=" ]; then
obj=${arg#NDK_OUT=}
elif [ "${arg:0:13}" == "NDK_LIBS_OUT=" ]; then
lib=${arg#NDK_LIBS_OUT=}
elif [ "${arg:0:13}" == "APP_PLATFORM=" ]; then
platform=${arg#APP_PLATFORM=}
elif [ "${arg:0:8}" == "APP_ABI=" ]; then
abi=${arg#APP_ABI=}
else
ndk_args="$ndk_args $arg"
fi
shift
done
if [ -z $obj ]; then
obj=$buildandroid/obj
fi
if [ -z $lib ]; then
lib=$buildandroid/lib
fi
for dir in $build $buildandroid $obj $lib; do
if test -d $dir; then
:
else
mkdir $dir || exit 1
fi
done
# APP_* variables set in the environment here will not be seen by the
# ndk-build makefile segments that use them, e.g., default-application.mk.
# For consistency, pass all values on the command line.
ndk-build \
NDK_PROJECT_PATH=null \
NDK_OUT=$obj \
NDK_LIBS_OUT=$lib \
APP_BUILD_SCRIPT=Android.mk \
APP_ABI="$abi" \
APP_PLATFORM="$platform" \
APP_MODULES="SDL2" \
$ndk_args
|