androidbuildlibs.sh 1.5 KB

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