androidbuildlibs.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/bin/bash
  2. #
  3. # Build the Android libraries without needing a project
  4. # (AndroidManifest.xml, jni/{Application,Android}.mk, etc.)
  5. #
  6. # Usage: androidbuildlibs.sh [arg for ndk-build ...]"
  7. #
  8. # Useful NDK arguments:
  9. #
  10. # NDK_DEBUG=1 - build debug version
  11. # NDK_LIBS_OUT=<dest> - specify alternate destination for installable
  12. # modules.
  13. #
  14. # Android.mk is in srcdir
  15. srcdir=`dirname $0`/..
  16. srcdir=`cd $srcdir && pwd`
  17. cd $srcdir
  18. #
  19. # Create the build directories
  20. #
  21. build=build
  22. buildandroid=$build/android
  23. platform=android-21
  24. abi="arm64-v8a" # "armeabi-v7a arm64-v8a x86 x86_64"
  25. obj=
  26. lib=
  27. ndk_args=
  28. flexpage=true
  29. # Allow an external caller to specify locations and platform.
  30. while [ $# -gt 0 ]; do
  31. arg=$1
  32. if [ "${arg:0:8}" == "NDK_OUT=" ]; then
  33. obj=${arg#NDK_OUT=}
  34. elif [ "${arg:0:13}" == "NDK_LIBS_OUT=" ]; then
  35. lib=${arg#NDK_LIBS_OUT=}
  36. elif [ "${arg:0:13}" == "APP_PLATFORM=" ]; then
  37. platform=${arg#APP_PLATFORM=}
  38. elif [ "${arg:0:8}" == "APP_ABI=" ]; then
  39. abi=${arg#APP_ABI=}
  40. elif [ "${arg:0:32}" == "APP_SUPPORT_FLEXIBLE_PAGE_SIZES=" ]; then
  41. flexpage=${arg#APP_SUPPORT_FLEXIBLE_PAGE_SIZES=}
  42. else
  43. ndk_args="$ndk_args $arg"
  44. fi
  45. shift
  46. done
  47. if [ -z $obj ]; then
  48. obj=$buildandroid/obj
  49. fi
  50. if [ -z $lib ]; then
  51. lib=$buildandroid/lib
  52. fi
  53. for dir in $build $buildandroid $obj $lib; do
  54. if test -d $dir; then
  55. :
  56. else
  57. mkdir $dir || exit 1
  58. fi
  59. done
  60. # APP_* variables set in the environment here will not be seen by the
  61. # ndk-build makefile segments that use them, e.g., default-application.mk.
  62. # For consistency, pass all values on the command line.
  63. #
  64. # Add support for Google Play 16 KB Page size requirement:
  65. # https://developer.android.com/guide/practices/page-sizes#ndk-build
  66. ndk-build \
  67. NDK_PROJECT_PATH=null \
  68. NDK_OUT=$obj \
  69. NDK_LIBS_OUT=$lib \
  70. APP_BUILD_SCRIPT=Android.mk \
  71. APP_ABI="$abi" \
  72. APP_PLATFORM="$platform" \
  73. APP_MODULES="SDL3" \
  74. APP_SUPPORT_FLEXIBLE_PAGE_SIZES="$flexpage" \
  75. $ndk_args