build.gradle 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. apply plugin: 'com.android.library'
  2. apply plugin: 'de.undercouch.download'
  3. android {
  4. compileSdkVersion 29
  5. buildToolsVersion '30.0.3'
  6. ndkVersion '22.0.7026061'
  7. defaultConfig {
  8. minSdkVersion 16
  9. targetSdkVersion 29
  10. externalNativeBuild {
  11. ndkBuild {
  12. arguments '-j' + Runtime.getRuntime().availableProcessors(),
  13. "versionMajor=${versionMajor}",
  14. "versionMinor=${versionMinor}",
  15. "versionPatch=${versionPatch}",
  16. "versionExtra=${versionExtra}"
  17. }
  18. }
  19. }
  20. externalNativeBuild {
  21. ndkBuild {
  22. path file('jni/Android.mk')
  23. }
  24. }
  25. // supported architectures
  26. splits {
  27. abi {
  28. enable true
  29. reset()
  30. include 'armeabi-v7a', 'arm64-v8a'//, 'x86'
  31. }
  32. }
  33. buildTypes {
  34. release {
  35. externalNativeBuild {
  36. ndkBuild {
  37. arguments 'NDEBUG=1'
  38. }
  39. }
  40. }
  41. }
  42. }
  43. // get precompiled deps
  44. def folder = 'minetest_android_deps_binaries'
  45. task downloadDeps(type: Download) {
  46. src 'https://github.com/minetest/' + folder + '/archive/master.zip'
  47. dest new File(buildDir, 'deps.zip')
  48. overwrite false
  49. }
  50. task getDeps(dependsOn: downloadDeps, type: Copy) {
  51. def deps = file('deps')
  52. def f = file("$buildDir/" + folder + "-master")
  53. if (!deps.exists() && !f.exists()) {
  54. from zipTree(downloadDeps.dest)
  55. into buildDir
  56. }
  57. doLast {
  58. if (!deps.exists()) {
  59. file(f).renameTo(file(deps))
  60. }
  61. }
  62. }
  63. // get sqlite
  64. def sqlite_ver = '3340000'
  65. task downloadSqlite(dependsOn: getDeps, type: Download) {
  66. src 'https://www.sqlite.org/2020/sqlite-amalgamation-' + sqlite_ver + '.zip'
  67. dest new File(buildDir, 'sqlite.zip')
  68. overwrite false
  69. }
  70. task getSqlite(dependsOn: downloadSqlite, type: Copy) {
  71. def sqlite = file('deps/Android/sqlite')
  72. def f = file("$buildDir/sqlite-amalgamation-" + sqlite_ver)
  73. if (!sqlite.exists() && !f.exists()) {
  74. from zipTree(downloadSqlite.dest)
  75. into buildDir
  76. }
  77. doLast {
  78. if (!sqlite.exists()) {
  79. file(f).renameTo(file(sqlite))
  80. }
  81. }
  82. }
  83. preBuild.dependsOn getDeps
  84. preBuild.dependsOn getSqlite