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