build-scripts/androidbuildlibs.sh
author Ryan C. Gordon <icculus@icculus.org>
Sun, 21 Oct 2018 22:40:17 -0400
changeset 12345 50e1cca28b39
parent 11836 a42b155124a3
child 12532 8db358c7a09a
permissions -rwxr-xr-x
wasapi/win32: Sort initial device lists by device GUID.

This makes an unchanged set of hardware always report devices in the same
order on each run.
slouken@11262
     1
#!/bin/sh
slouken@11262
     2
#
slouken@11262
     3
# Build the Android libraries without needing a project
slouken@11262
     4
# (AndroidManifest.xml, jni/{Application,Android}.mk, etc.)
slouken@11262
     5
#
slouken@11262
     6
# Usage: androidbuildlibs.sh [arg for ndk-build ...]"
slouken@11262
     7
#
slouken@11262
     8
# Useful NDK arguments:
slouken@11262
     9
#
slouken@11262
    10
#  NDK_DEBUG=1          - build debug version
slouken@11262
    11
#  NDK_LIBS_OUT=<dest>  - specify alternate destination for installable
slouken@11262
    12
#                         modules.
slouken@11262
    13
#
slouken@11262
    14
# Note that SDLmain is not an installable module (.so) so libSDLmain.a
slouken@11262
    15
# can be found in $obj/local/<abi> along with the unstripped libSDL.so.
slouken@11262
    16
#
slouken@11262
    17
slouken@11262
    18
slouken@11262
    19
# Android.mk is in srcdir
slouken@11262
    20
srcdir=`dirname $0`/..
slouken@11262
    21
srcdir=`cd $srcdir && pwd`
slouken@11262
    22
cd $srcdir
slouken@11262
    23
slouken@11262
    24
slouken@11262
    25
#
slouken@11262
    26
# Create the build directories
slouken@11262
    27
#
slouken@11262
    28
slouken@11262
    29
build=build
slouken@11262
    30
buildandroid=$build/android
slouken@11262
    31
obj=
slouken@11262
    32
lib=
slouken@11262
    33
ndk_args=
slouken@11262
    34
slouken@11262
    35
# Allow an external caller to specify locations.
slouken@11262
    36
for arg in $*
slouken@11262
    37
do
slouken@11262
    38
  if [ "${arg:0:8}" == "NDK_OUT=" ]; then
slouken@11262
    39
	obj=${arg#NDK_OUT=}
slouken@11262
    40
  elif [ "${arg:0:13}" == "NDK_LIBS_OUT=" ]; then
slouken@11262
    41
	lib=${arg#NDK_LIBS_OUT=}
slouken@11262
    42
  else
slouken@11262
    43
    ndk_args="$ndk_args $arg"
slouken@11262
    44
  fi
slouken@11262
    45
done
slouken@11262
    46
slouken@11262
    47
if [ -z $obj ]; then
slouken@11262
    48
  obj=$buildandroid/obj
slouken@11262
    49
fi
slouken@11262
    50
if [ -z $lib ]; then
slouken@11262
    51
  lib=$buildandroid/lib
slouken@11262
    52
fi
slouken@11262
    53
slouken@11262
    54
for dir in $build $buildandroid $obj $lib; do
slouken@11262
    55
    if test -d $dir; then
slouken@11262
    56
        :
slouken@11262
    57
    else
slouken@11262
    58
        mkdir $dir || exit 1
slouken@11262
    59
    fi
slouken@11262
    60
done
slouken@11262
    61
slouken@11262
    62
slouken@11262
    63
# APP_* variables set in the environment here will not be seen by the
slouken@11262
    64
# ndk-build makefile segments that use them, e.g., default-application.mk.
slouken@11262
    65
# For consistency, pass all values on the command line.
slouken@11262
    66
ndk-build \
slouken@11262
    67
  NDK_PROJECT_PATH=null \
slouken@11262
    68
  NDK_OUT=$obj \
slouken@11262
    69
  NDK_LIBS_OUT=$lib \
slouken@11262
    70
  APP_BUILD_SCRIPT=Android.mk \
slouken@11836
    71
  APP_ABI="armeabi-v7a arm64-v8a x86 x86_64" \
slouken@11836
    72
  APP_PLATFORM=android-14 \
slouken@11262
    73
  APP_MODULES="SDL2 SDL2_main" \
slouken@11262
    74
  $ndk_args