diff options
Diffstat (limited to 'platform/android/java/lib/build.gradle')
| -rw-r--r-- | platform/android/java/lib/build.gradle | 69 | 
1 files changed, 51 insertions, 18 deletions
diff --git a/platform/android/java/lib/build.gradle b/platform/android/java/lib/build.gradle index eb97484b9c..663ba73d40 100644 --- a/platform/android/java/lib/build.gradle +++ b/platform/android/java/lib/build.gradle @@ -1,7 +1,10 @@  apply plugin: 'com.android.library' +apply plugin: 'kotlin-android'  dependencies {      implementation libraries.supportCoreUtils +    implementation libraries.kotlinStdLib +    implementation libraries.v4Support  }  def pathToRootDir = "../../../../" @@ -9,11 +12,19 @@ def pathToRootDir = "../../../../"  android {      compileSdkVersion versions.compileSdk      buildToolsVersion versions.buildTools -    useLibrary 'org.apache.http.legacy' + +    ndkVersion versions.ndkVersion      defaultConfig {          minSdkVersion versions.minSdk          targetSdkVersion versions.targetSdk + +        manifestPlaceholders = [godotLibraryVersion: getGodotLibraryVersion()] +    } + +    compileOptions { +        sourceCompatibility versions.javaVersion +        targetCompatibility versions.javaVersion      }      lintOptions { @@ -24,6 +35,11 @@ android {      packagingOptions {          exclude 'META-INF/LICENSE'          exclude 'META-INF/NOTICE' + +        // 'doNotStrip' is enabled for development within Android Studio +        if (shouldNotStrip()) { +            doNotStrip '**/*.so' +        }      }      sourceSets { @@ -45,16 +61,7 @@ android {          def buildType = variant.buildType.name.capitalize() -        def taskPrefix = "" -        if (project.path != ":") { -            taskPrefix = project.path + ":" -        } - -        // Disable the externalNativeBuild* task as it would cause build failures since the cmake build -        // files is only setup for editing support. -        gradle.startParameter.excludedTaskNames += taskPrefix + "externalNativeBuild" + buildType - -        def releaseTarget = supportedTargets[buildType.toLowerCase()] +        def releaseTarget = buildType.toLowerCase()          if (releaseTarget == null || releaseTarget == "") {              throw new GradleException("Invalid build type: " + buildType)          } @@ -63,20 +70,46 @@ android {              throw new GradleException("Invalid default abi: " + defaultAbi)          } +        // Find scons' executable path +        File sconsExecutableFile = null +        def sconsName = "scons" +        def sconsExts = (org.gradle.internal.os.OperatingSystem.current().isWindows() +            ? [".bat", ".cmd", ".ps1", ".exe"] +            : [""]) +        logger.lifecycle("Looking for $sconsName executable path") +        for (ext in sconsExts) { +            String sconsNameExt = sconsName + ext +            logger.lifecycle("Checking $sconsNameExt") + +            sconsExecutableFile = org.gradle.internal.os.OperatingSystem.current().findInPath(sconsNameExt) +            if (sconsExecutableFile != null) { +                // We're done! +                break +            } + +            // Check all the options in path +            List<File> allOptions = org.gradle.internal.os.OperatingSystem.current().findAllInPath(sconsNameExt) +            if (!allOptions.isEmpty()) { +                // Pick the first option and we're done! +                sconsExecutableFile = allOptions.get(0) +                break +            } +        } + +        if (sconsExecutableFile == null) { +            throw new GradleException("Unable to find executable path for the '$sconsName' command.") +        } else { +            logger.lifecycle("Found executable path for $sconsName: ${sconsExecutableFile.absolutePath}") +        } +          // Creating gradle task to generate the native libraries for the default abi.          def taskName = getSconsTaskName(buildType)          tasks.create(name: taskName, type: Exec) { -            executable "scons" + sconsExt +            executable sconsExecutableFile.absolutePath              args "--directory=${pathToRootDir}", "platform=android", "target=${releaseTarget}", "android_arch=${defaultAbi}", "-j" + Runtime.runtime.availableProcessors()          }          // Schedule the tasks so the generated libs are present before the aar file is packaged.          tasks["merge${buildType}JniLibFolders"].dependsOn taskName      } - -    externalNativeBuild { -        cmake { -            path "CMakeLists.txt" -        } -    }  }  |