androidbuildlibs.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. obj=
  24. lib=
  25. ndk_args=
  26. # Allow overriding the ABI from the environment
  27. if [ "$APP_ABI" = "" ]; then
  28. #APP_ABI="armeabi-v7a arm64-v8a x86 x86_64"
  29. APP_ABI="arm64-v8a"
  30. fi
  31. # Allow overriding the platform from the environment
  32. if [ "$APP_PLATFORM" = "" ]; then
  33. APP_PLATFORM=android-16
  34. fi
  35. # Allow an external caller to specify locations.
  36. for arg in $*; do
  37. if [ "${arg:0:8}" == "NDK_OUT=" ]; then
  38. obj=${arg#NDK_OUT=}
  39. elif [ "${arg:0:13}" == "NDK_LIBS_OUT=" ]; then
  40. lib=${arg#NDK_LIBS_OUT=}
  41. else
  42. ndk_args="$ndk_args $arg"
  43. fi
  44. done
  45. if [ -z $obj ]; then
  46. obj=$buildandroid/obj
  47. fi
  48. if [ -z $lib ]; then
  49. lib=$buildandroid/lib
  50. fi
  51. for dir in $build $buildandroid $obj $lib; do
  52. if test -d $dir; then
  53. :
  54. else
  55. mkdir $dir || exit 1
  56. fi
  57. done
  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="$APP_ABI" \
  67. APP_PLATFORM="$APP_PLATFORM" \
  68. APP_MODULES="SDL3" \
  69. $ndk_args