2019-09-03 02:31:51 +02:00
|
|
|
apply plugin: 'com.android.library'
|
2020-03-27 06:42:18 +01:00
|
|
|
apply plugin: 'kotlin-android'
|
2019-09-03 02:31:51 +02:00
|
|
|
|
2022-03-14 17:19:04 +01:00
|
|
|
ext {
|
|
|
|
PUBLISH_VERSION = getGodotPublishVersion()
|
|
|
|
PUBLISH_ARTIFACT_ID = 'godot'
|
|
|
|
}
|
|
|
|
|
|
|
|
apply from: "../scripts/publish-module.gradle"
|
|
|
|
|
2019-09-03 02:31:51 +02:00
|
|
|
dependencies {
|
2020-03-27 06:42:18 +01:00
|
|
|
implementation libraries.kotlinStdLib
|
2021-08-31 12:02:59 +02:00
|
|
|
implementation libraries.androidxFragment
|
2019-09-03 02:31:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
def pathToRootDir = "../../../../"
|
|
|
|
|
|
|
|
android {
|
|
|
|
compileSdkVersion versions.compileSdk
|
|
|
|
buildToolsVersion versions.buildTools
|
2021-02-18 01:31:31 +01:00
|
|
|
ndkVersion versions.ndkVersion
|
|
|
|
|
2019-09-03 02:31:51 +02:00
|
|
|
defaultConfig {
|
|
|
|
minSdkVersion versions.minSdk
|
|
|
|
targetSdkVersion versions.targetSdk
|
2021-02-24 12:49:00 +01:00
|
|
|
|
2021-06-25 15:45:16 +02:00
|
|
|
manifestPlaceholders = [godotLibraryVersion: getGodotLibraryVersionName()]
|
2019-09-03 02:31:51 +02:00
|
|
|
}
|
|
|
|
|
2022-03-14 17:19:04 +01:00
|
|
|
namespace = "org.godotengine.godot"
|
|
|
|
|
2020-10-29 00:32:45 +01:00
|
|
|
compileOptions {
|
|
|
|
sourceCompatibility versions.javaVersion
|
|
|
|
targetCompatibility versions.javaVersion
|
|
|
|
}
|
|
|
|
|
2021-06-25 15:45:16 +02:00
|
|
|
buildTypes {
|
|
|
|
release_debug {
|
|
|
|
initWith debug
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
flavorDimensions "tools"
|
|
|
|
productFlavors {
|
|
|
|
toolsEnabled {}
|
|
|
|
toolsDisabled {}
|
|
|
|
}
|
|
|
|
|
2019-09-03 02:31:51 +02:00
|
|
|
lintOptions {
|
|
|
|
abortOnError false
|
|
|
|
disable 'MissingTranslation', 'UnusedResources'
|
|
|
|
}
|
|
|
|
|
|
|
|
packagingOptions {
|
|
|
|
exclude 'META-INF/LICENSE'
|
|
|
|
exclude 'META-INF/NOTICE'
|
2020-04-23 09:21:39 +02:00
|
|
|
|
2021-03-10 09:14:57 +01:00
|
|
|
// 'doNotStrip' is enabled for development within Android Studio
|
|
|
|
if (shouldNotStrip()) {
|
|
|
|
doNotStrip '**/*.so'
|
|
|
|
}
|
2019-09-03 02:31:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
main {
|
|
|
|
manifest.srcFile 'AndroidManifest.xml'
|
|
|
|
java.srcDirs = ['src']
|
|
|
|
res.srcDirs = ['res']
|
|
|
|
aidl.srcDirs = ['aidl']
|
|
|
|
assets.srcDirs = ['assets']
|
|
|
|
}
|
2021-06-25 15:45:16 +02:00
|
|
|
|
2019-09-03 02:31:51 +02:00
|
|
|
debug.jniLibs.srcDirs = ['libs/debug']
|
2021-06-25 15:45:16 +02:00
|
|
|
release_debug.jniLibs.srcDirs = ['libs/release_debug']
|
2019-09-03 02:31:51 +02:00
|
|
|
release.jniLibs.srcDirs = ['libs/release']
|
2021-06-25 15:45:16 +02:00
|
|
|
|
|
|
|
// Tools enabled jni library
|
|
|
|
toolsEnabledDebug.jniLibs.srcDirs = ['libs/tools/debug']
|
|
|
|
toolsEnabledRelease_debug.jniLibs.srcDirs = ['libs/tools/release_debug']
|
|
|
|
toolsEnabledRelease.jniLibs.srcDirs = ['libs/tools/release']
|
2019-09-03 02:31:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
libraryVariants.all { variant ->
|
2021-06-25 15:45:16 +02:00
|
|
|
def flavorName = variant.getFlavorName()
|
|
|
|
def buildType = variant.buildType.name.capitalize()
|
|
|
|
|
|
|
|
if (flavorName == null || flavorName == "") {
|
|
|
|
throw new GradleException("Invalid product flavor: $flavorName")
|
2019-09-03 02:31:51 +02:00
|
|
|
}
|
|
|
|
|
2021-06-25 15:45:16 +02:00
|
|
|
boolean toolsFlag = flavorName == "toolsEnabled"
|
2019-09-03 02:31:51 +02:00
|
|
|
|
2020-03-08 12:34:44 +01:00
|
|
|
def releaseTarget = buildType.toLowerCase()
|
2019-09-23 07:23:59 +02:00
|
|
|
if (releaseTarget == null || releaseTarget == "") {
|
|
|
|
throw new GradleException("Invalid build type: " + buildType)
|
2019-09-03 02:31:51 +02:00
|
|
|
}
|
|
|
|
|
2021-06-25 15:45:16 +02:00
|
|
|
// Update the name of the generated library
|
|
|
|
def outputSuffix = "${releaseTarget}.aar"
|
|
|
|
if (toolsFlag) {
|
|
|
|
outputSuffix = "tools.$outputSuffix"
|
|
|
|
}
|
|
|
|
variant.outputs.all { output ->
|
|
|
|
output.outputFileName = "godot-lib.${outputSuffix}"
|
2019-09-03 02:31:51 +02:00
|
|
|
}
|
|
|
|
|
2020-11-14 23:36:53 +01:00
|
|
|
// Find scons' executable path
|
|
|
|
File sconsExecutableFile = null
|
|
|
|
def sconsName = "scons"
|
|
|
|
def sconsExts = (org.gradle.internal.os.OperatingSystem.current().isWindows()
|
2021-01-30 13:13:01 +01:00
|
|
|
? [".bat", ".cmd", ".ps1", ".exe"]
|
2020-11-14 23:36:53 +01:00
|
|
|
: [""])
|
|
|
|
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}")
|
|
|
|
}
|
|
|
|
|
2021-06-25 15:45:16 +02:00
|
|
|
for (String selectedAbi : selectedAbis) {
|
|
|
|
if (!supportedAbis.contains(selectedAbi)) {
|
|
|
|
throw new GradleException("Invalid selected abi: " + selectedAbi)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Creating gradle task to generate the native libraries for the selected abi.
|
|
|
|
def taskName = getSconsTaskName(flavorName, buildType, selectedAbi)
|
|
|
|
tasks.create(name: taskName, type: Exec) {
|
|
|
|
executable sconsExecutableFile.absolutePath
|
|
|
|
args "--directory=${pathToRootDir}", "platform=android", "tools=${toolsFlag}", "target=${releaseTarget}", "android_arch=${selectedAbi}", "-j" + Runtime.runtime.availableProcessors()
|
|
|
|
}
|
2019-09-03 02:31:51 +02:00
|
|
|
|
2021-06-25 15:45:16 +02:00
|
|
|
// Schedule the tasks so the generated libs are present before the aar file is packaged.
|
|
|
|
tasks["merge${flavorName.capitalize()}${buildType}JniLibFolders"].dependsOn taskName
|
|
|
|
}
|
2019-09-03 02:31:51 +02:00
|
|
|
}
|
2022-03-14 17:19:04 +01:00
|
|
|
|
|
|
|
// TODO: Enable when issues with AGP 7.1+ are resolved (https://github.com/GodotVR/godot_openxr/issues/187).
|
|
|
|
// publishing {
|
|
|
|
// singleVariant("release") {
|
|
|
|
// withSourcesJar()
|
|
|
|
// withJavadocJar()
|
|
|
|
// }
|
|
|
|
// }
|
2019-09-03 02:31:51 +02:00
|
|
|
}
|