Merge pull request #66935 from m4gr3d/fix_android_build_configuration
Fix the gradle build configuration for the Android platform
This commit is contained in:
commit
8afa178c6f
@ -53,10 +53,10 @@ else:
|
|||||||
print("WARN: Architecture not suitable for embedding into APK; keeping .so at \\bin")
|
print("WARN: Architecture not suitable for embedding into APK; keeping .so at \\bin")
|
||||||
|
|
||||||
if lib_arch_dir != "":
|
if lib_arch_dir != "":
|
||||||
if env.debug_features:
|
if env.dev_build:
|
||||||
lib_type_dir = "debug"
|
|
||||||
elif env.dev_build:
|
|
||||||
lib_type_dir = "dev"
|
lib_type_dir = "dev"
|
||||||
|
elif env.debug_features:
|
||||||
|
lib_type_dir = "debug"
|
||||||
else: # Release
|
else: # Release
|
||||||
lib_type_dir = "release"
|
lib_type_dir = "release"
|
||||||
|
|
||||||
|
@ -29,8 +29,13 @@ allprojects {
|
|||||||
|
|
||||||
ext {
|
ext {
|
||||||
supportedAbis = ["arm32", "arm64", "x86_32", "x86_64"]
|
supportedAbis = ["arm32", "arm64", "x86_32", "x86_64"]
|
||||||
supportedTargetsMap = [release: "release", dev: "debug", debug: "release_debug"]
|
|
||||||
supportedFlavors = ["editor", "template"]
|
supportedFlavors = ["editor", "template"]
|
||||||
|
supportedFlavorsBuildTypes = [
|
||||||
|
// The editor can't be used with target=release as debugging tools are then not
|
||||||
|
// included, and it would crash on errors instead of reporting them.
|
||||||
|
"editor": ["dev", "debug"],
|
||||||
|
"template": ["dev", "debug", "release"]
|
||||||
|
]
|
||||||
|
|
||||||
// Used by gradle to specify which architecture to build for by default when running
|
// Used by gradle to specify which architecture to build for by default when running
|
||||||
// `./gradlew build` (this command is usually used by Android Studio).
|
// `./gradlew build` (this command is usually used by Android Studio).
|
||||||
@ -88,7 +93,7 @@ task copyDebugAARToAppModule(type: Copy) {
|
|||||||
dependsOn ':lib:assembleTemplateDebug'
|
dependsOn ':lib:assembleTemplateDebug'
|
||||||
from('lib/build/outputs/aar')
|
from('lib/build/outputs/aar')
|
||||||
into('app/libs/debug')
|
into('app/libs/debug')
|
||||||
include('godot-lib.debug.aar')
|
include('godot-lib.template_debug.aar')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,7 +104,7 @@ task copyDebugAARToBin(type: Copy) {
|
|||||||
dependsOn ':lib:assembleTemplateDebug'
|
dependsOn ':lib:assembleTemplateDebug'
|
||||||
from('lib/build/outputs/aar')
|
from('lib/build/outputs/aar')
|
||||||
into(binDir)
|
into(binDir)
|
||||||
include('godot-lib.debug.aar')
|
include('godot-lib.template_debug.aar')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,7 +115,7 @@ task copyDevAARToAppModule(type: Copy) {
|
|||||||
dependsOn ':lib:assembleTemplateDev'
|
dependsOn ':lib:assembleTemplateDev'
|
||||||
from('lib/build/outputs/aar')
|
from('lib/build/outputs/aar')
|
||||||
into('app/libs/dev')
|
into('app/libs/dev')
|
||||||
include('godot-lib.dev.aar')
|
include('godot-lib.template_debug.dev.aar')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,7 +126,7 @@ task copyDevAARToBin(type: Copy) {
|
|||||||
dependsOn ':lib:assembleTemplateDev'
|
dependsOn ':lib:assembleTemplateDev'
|
||||||
from('lib/build/outputs/aar')
|
from('lib/build/outputs/aar')
|
||||||
into(binDir)
|
into(binDir)
|
||||||
include('godot-lib.dev.aar')
|
include('godot-lib.template_debug.dev.aar')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,7 +137,7 @@ task copyReleaseAARToAppModule(type: Copy) {
|
|||||||
dependsOn ':lib:assembleTemplateRelease'
|
dependsOn ':lib:assembleTemplateRelease'
|
||||||
from('lib/build/outputs/aar')
|
from('lib/build/outputs/aar')
|
||||||
into('app/libs/release')
|
into('app/libs/release')
|
||||||
include('godot-lib.release.aar')
|
include('godot-lib.template_release.aar')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,7 +148,7 @@ task copyReleaseAARToBin(type: Copy) {
|
|||||||
dependsOn ':lib:assembleTemplateRelease'
|
dependsOn ':lib:assembleTemplateRelease'
|
||||||
from('lib/build/outputs/aar')
|
from('lib/build/outputs/aar')
|
||||||
into(binDir)
|
into(binDir)
|
||||||
include('godot-lib.release.aar')
|
include('godot-lib.template_release.aar')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -168,13 +173,8 @@ def templateExcludedBuildTask() {
|
|||||||
if (!isAndroidStudio()) {
|
if (!isAndroidStudio()) {
|
||||||
logger.lifecycle("Excluding Android studio build tasks")
|
logger.lifecycle("Excluding Android studio build tasks")
|
||||||
for (String flavor : supportedFlavors) {
|
for (String flavor : supportedFlavors) {
|
||||||
for (String buildType : supportedTargetsMap.keySet()) {
|
String[] supportedBuildTypes = supportedFlavorsBuildTypes[flavor]
|
||||||
if (buildType == "release" && flavor == "editor") {
|
for (String buildType : supportedBuildTypes) {
|
||||||
// The editor can't be used with target=release as debugging tools are then not
|
|
||||||
// included, and it would crash on errors instead of reporting them.
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String abi : selectedAbis) {
|
for (String abi : selectedAbis) {
|
||||||
excludedTasks += ":lib:" + getSconsTaskName(flavor, buildType, abi)
|
excludedTasks += ":lib:" + getSconsTaskName(flavor, buildType, abi)
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ def templateBuildTasks() {
|
|||||||
def tasks = []
|
def tasks = []
|
||||||
|
|
||||||
// Only build the apks and aar files for which we have native shared libraries.
|
// Only build the apks and aar files for which we have native shared libraries.
|
||||||
for (String target : supportedTargetsMap.keySet()) {
|
for (String target : supportedFlavorsBuildTypes["template"]) {
|
||||||
File targetLibs = new File("lib/libs/" + target)
|
File targetLibs = new File("lib/libs/" + target)
|
||||||
if (targetLibs != null
|
if (targetLibs != null
|
||||||
&& targetLibs.isDirectory()
|
&& targetLibs.isDirectory()
|
||||||
@ -240,12 +240,7 @@ task generateGodotEditor {
|
|||||||
|
|
||||||
def tasks = []
|
def tasks = []
|
||||||
|
|
||||||
for (String target : supportedTargetsMap.keySet()) {
|
for (String target : supportedFlavorsBuildTypes["editor"]) {
|
||||||
if (target == "release") {
|
|
||||||
// The editor can't be used with target=release as debugging tools are then not
|
|
||||||
// included, and it would crash on errors instead of reporting them.
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
File targetLibs = new File("lib/libs/tools/" + target)
|
File targetLibs = new File("lib/libs/tools/" + target)
|
||||||
if (targetLibs != null
|
if (targetLibs != null
|
||||||
&& targetLibs.isDirectory()
|
&& targetLibs.isDirectory()
|
||||||
@ -322,9 +317,9 @@ task cleanGodotTemplates(type: Delete) {
|
|||||||
delete("$binDir/android_dev.apk")
|
delete("$binDir/android_dev.apk")
|
||||||
delete("$binDir/android_release.apk")
|
delete("$binDir/android_release.apk")
|
||||||
delete("$binDir/android_source.zip")
|
delete("$binDir/android_source.zip")
|
||||||
delete("$binDir/godot-lib.debug.aar")
|
delete("$binDir/godot-lib.template_debug.aar")
|
||||||
delete("$binDir/godot-lib.dev.aar")
|
delete("$binDir/godot-lib.template_debug.dev.aar")
|
||||||
delete("$binDir/godot-lib.release.aar")
|
delete("$binDir/godot-lib.template_release.aar")
|
||||||
|
|
||||||
finalizedBy getTasksByName("clean", true)
|
finalizedBy getTasksByName("clean", true)
|
||||||
}
|
}
|
||||||
|
@ -100,25 +100,34 @@ android {
|
|||||||
throw new GradleException("Invalid product flavor: $flavorName")
|
throw new GradleException("Invalid product flavor: $flavorName")
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean toolsFlag = flavorName == "editor"
|
|
||||||
|
|
||||||
def buildType = variant.buildType.name
|
def buildType = variant.buildType.name
|
||||||
if (buildType == null || buildType == "" || !supportedTargetsMap.containsKey(buildType)) {
|
if (buildType == null || buildType == "" || !supportedFlavorsBuildTypes[flavorName].contains(buildType)) {
|
||||||
throw new GradleException("Invalid build type: $buildType")
|
throw new GradleException("Invalid build type: $buildType")
|
||||||
}
|
}
|
||||||
|
|
||||||
def sconsTarget = supportedTargetsMap[buildType]
|
boolean devBuild = buildType == "dev"
|
||||||
if (sconsTarget == null || sconsTarget == "") {
|
|
||||||
throw new GradleException("Invalid scons target: $sconsTarget")
|
def sconsTarget = flavorName
|
||||||
|
if (sconsTarget == "template") {
|
||||||
|
switch (buildType) {
|
||||||
|
case "release":
|
||||||
|
sconsTarget += "_release"
|
||||||
|
break
|
||||||
|
case "debug":
|
||||||
|
case "dev":
|
||||||
|
default:
|
||||||
|
sconsTarget += "_debug"
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the name of the generated library
|
// Update the name of the generated library
|
||||||
def outputSuffix = "${buildType}.aar"
|
def outputSuffix = "${sconsTarget}"
|
||||||
if (toolsFlag) {
|
if (devBuild) {
|
||||||
outputSuffix = "tools.$outputSuffix"
|
outputSuffix = "${outputSuffix}.dev"
|
||||||
}
|
}
|
||||||
variant.outputs.all { output ->
|
variant.outputs.all { output ->
|
||||||
output.outputFileName = "godot-lib.${outputSuffix}"
|
output.outputFileName = "godot-lib.${outputSuffix}.aar"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find scons' executable path
|
// Find scons' executable path
|
||||||
@ -159,7 +168,7 @@ android {
|
|||||||
def taskName = getSconsTaskName(flavorName, buildType, selectedAbi)
|
def taskName = getSconsTaskName(flavorName, buildType, selectedAbi)
|
||||||
tasks.create(name: taskName, type: Exec) {
|
tasks.create(name: taskName, type: Exec) {
|
||||||
executable sconsExecutableFile.absolutePath
|
executable sconsExecutableFile.absolutePath
|
||||||
args "--directory=${pathToRootDir}", "platform=android", "tools=${toolsFlag}", "target=${sconsTarget}", "arch=${selectedAbi}", "-j" + Runtime.runtime.availableProcessors()
|
args "--directory=${pathToRootDir}", "platform=android", "dev_mode=${devBuild}", "dev_build=${devBuild}", "target=${sconsTarget}", "arch=${selectedAbi}", "-j" + Runtime.runtime.availableProcessors()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Schedule the tasks so the generated libs are present before the aar file is packaged.
|
// Schedule the tasks so the generated libs are present before the aar file is packaged.
|
||||||
|
Loading…
Reference in New Issue
Block a user