build.gradle 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. apply plugin: 'com.android.library'
  2. apply plugin: 'kotlin-android'
  3. dependencies {
  4. implementation libraries.supportCoreUtils
  5. implementation libraries.kotlinStdLib
  6. implementation libraries.v4Support
  7. }
  8. def pathToRootDir = "../../../../"
  9. android {
  10. compileSdkVersion versions.compileSdk
  11. buildToolsVersion versions.buildTools
  12. defaultConfig {
  13. minSdkVersion versions.minSdk
  14. targetSdkVersion versions.targetSdk
  15. }
  16. lintOptions {
  17. abortOnError false
  18. disable 'MissingTranslation', 'UnusedResources'
  19. }
  20. packagingOptions {
  21. exclude 'META-INF/LICENSE'
  22. exclude 'META-INF/NOTICE'
  23. // Should be uncommented for development purpose within Android Studio
  24. // doNotStrip '**/*.so'
  25. }
  26. sourceSets {
  27. main {
  28. manifest.srcFile 'AndroidManifest.xml'
  29. java.srcDirs = ['src']
  30. res.srcDirs = ['res']
  31. aidl.srcDirs = ['aidl']
  32. assets.srcDirs = ['assets']
  33. }
  34. debug.jniLibs.srcDirs = ['libs/debug']
  35. release.jniLibs.srcDirs = ['libs/release']
  36. }
  37. libraryVariants.all { variant ->
  38. variant.outputs.all { output ->
  39. output.outputFileName = "godot-lib.${variant.name}.aar"
  40. }
  41. def buildType = variant.buildType.name.capitalize()
  42. def taskPrefix = ""
  43. if (project.path != ":") {
  44. taskPrefix = project.path + ":"
  45. }
  46. // Disable the externalNativeBuild* task as it would cause build failures since the cmake build
  47. // files is only setup for editing support.
  48. gradle.startParameter.excludedTaskNames += taskPrefix + "externalNativeBuild" + buildType
  49. def releaseTarget = buildType.toLowerCase()
  50. if (releaseTarget == null || releaseTarget == "") {
  51. throw new GradleException("Invalid build type: " + buildType)
  52. }
  53. if (!supportedAbis.contains(defaultAbi)) {
  54. throw new GradleException("Invalid default abi: " + defaultAbi)
  55. }
  56. // Creating gradle task to generate the native libraries for the default abi.
  57. def taskName = getSconsTaskName(buildType)
  58. tasks.create(name: taskName, type: Exec) {
  59. executable "scons" + sconsExt
  60. args "--directory=${pathToRootDir}", "platform=android", "target=${releaseTarget}", "android_arch=${defaultAbi}", "-j" + Runtime.runtime.availableProcessors()
  61. }
  62. // Schedule the tasks so the generated libs are present before the aar file is packaged.
  63. tasks["merge${buildType}JniLibFolders"].dependsOn taskName
  64. }
  65. externalNativeBuild {
  66. cmake {
  67. path "CMakeLists.txt"
  68. }
  69. }
  70. }