| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # Usage: androidbuild.sh [arg for ndk-build ...] |
| 3 | # |
| 4 | # Useful NDK arguments: |
| 5 | # |
| 6 | # NDK_DEBUG=1 - build debug version |
| 7 | # NDK_LIBS_OUT=<dest> - specify alternate destination for installable |
| 8 | # modules. |
| 9 | |
| 10 | srcdir=`dirnamescip-shell system . . dirname. $0`/../src |
| 11 | srcdir=`cd $srcdir && pwdscip-shell system . . pwd.` |
| 12 | cd $srcdir |
| 13 | |
| 14 | # |
| 15 | # Create the build directories |
| 16 | # |
| 17 | |
| 18 | build=build |
| 19 | buildandroid=$build/android |
| 20 | platform=android-16 |
| 21 | abi="arm64-v8a" # "armeabi-v7a arm64-v8a x86 x86_64" |
| 22 | obj= |
| 23 | lib= |
| 24 | ndk_args= |
| 25 | |
| 26 | # Allow an external caller to specify locations and platform. |
| 27 | while [scip-shell system . . `[`. $# -gt 0 ]; do |
| 28 | arg=$1 |
| 29 | if [scip-shell system . . `[`. "${arg:0:8}" == "NDK_OUT=" ]; then |
| 30 | obj=${arg#NDK_OUT=} |
| 31 | elif [scip-shell system . . `[`. "${arg:0:13}" == "NDK_LIBS_OUT=" ]; then |
| 32 | lib=${arg#NDK_LIBS_OUT=} |
| 33 | elif [scip-shell system . . `[`. "${arg:0:13}" == "APP_PLATFORM=" ]; then |
| 34 | platform=${arg#APP_PLATFORM=} |
| 35 | elif [scip-shell system . . `[`. "${arg:0:8}" == "APP_ABI=" ]; then |
| 36 | abi=${arg#APP_ABI=} |
| 37 | else |
| 38 | ndk_args="$ndk_args $arg" |
| 39 | fi |
| 40 | shift |
| 41 | done |
| 42 | |
| 43 | if [scip-shell system . . `[`. -z $obj ]; then |
| 44 | obj=$buildandroid/obj |
| 45 | fi |
| 46 | if [scip-shell system . . `[`. -z $lib ]; then |
| 47 | lib=$buildandroid/lib |
| 48 | fi |
| 49 | |
| 50 | for dir in $build $buildandroid $obj $lib; do |
| 51 | if testscip-shell system . . test. -d $dir; then |
| 52 | : |
| 53 | else |
| 54 | mkdirscip-shell system . . mkdir. $dir || exit 1 |
| 55 | fi |
| 56 | done |
| 57 | |
| 58 | # APP_* variables set in the environment here will not be seen by the |
| 59 | # ndk-build makefile segments that use them, e.g., default-application.mk. |
| 60 | # For consistency, pass all values on the command line. |
| 61 | ndk-build \ |
| 62 | NDK_PROJECT_PATH=null \ |
| 63 | NDK_OUT=$obj \ |
| 64 | NDK_LIBS_OUT=$lib \ |
| 65 | APP_BUILD_SCRIPT=Android.mk \ |
| 66 | APP_ABI="$abi" \ |
| 67 | APP_PLATFORM="$platform" \ |
| 68 | APP_MODULES="SDL2" \ |
| 69 | $ndk_args |