androidbuildlibs.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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-16
  24. abi="arm64-v8a" # "armeabi-v7a arm64-v8a x86 x86_64"
  25. obj=
  26. lib=
  27. ndk_args=
  28. # Allow an external caller to specify locations and platform.
  29. while [ $# -gt 0 ]; do
  30. arg=$1
  31. if [ "${arg:0:8}" == "NDK_OUT=" ]; then
  32. obj=${arg#NDK_OUT=}
  33. elif [ "${arg:0:13}" == "NDK_LIBS_OUT=" ]; then
  34. lib=${arg#NDK_LIBS_OUT=}
  35. elif [ "${arg:0:13}" == "APP_PLATFORM=" ]; then
  36. platform=${arg#APP_PLATFORM=}
  37. elif [ "${arg:0:8}" == "APP_ABI=" ]; then
  38. abi=${arg#APP_ABI=}
  39. else
  40. ndk_args="$ndk_args $arg"
  41. fi
  42. shift
  43. done
  44. if [ -z $obj ]; then
  45. obj=$buildandroid/obj
  46. fi
  47. if [ -z $lib ]; then
  48. lib=$buildandroid/lib
  49. fi
  50. for dir in $build $buildandroid $obj $lib; do
  51. if test -d $dir; then
  52. :
  53. else
  54. mkdir $dir || exit 1
  55. fi
  56. done
  57. # APP_* variables set in the environment here will not be seen by the
  58. # ndk-build makefile segments that use them, e.g., default-application.mk.
  59. # For consistency, pass all values on the command line.
  60. ndk-build \
  61. NDK_PROJECT_PATH=null \
  62. NDK_OUT=$obj \
  63. NDK_LIBS_OUT=$lib \
  64. APP_BUILD_SCRIPT=Android.mk \
  65. APP_ABI="$abi" \
  66. APP_PLATFORM="$platform" \
  67. APP_MODULES="SDL3" \
  68. $ndk_args