1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Updates the Godot gradle tasks to enable manual runs of the scons command.

Example: To generate for the `release` build target and for the `armv7`, `arm64v8` and `x86` architectures, run the commands:
```
cd godot
scons -j4 platform=android target=release android_arch=armv7
scons -j4 platform=android target=release android_arch=arm64v8
scons -j4 platform=android target=release android_arch=x86
cd platform/android/java
./gradlew generateGodotTemplates
```

Notes:
- The generated build templates will be located in the `godot/bin` directory (i.e: `android_debug.apk`, `android_release.apk`, `android_source.zip`).
- The gradle command will only generate templates for the target(s) with available native shared libraries. For example, running the commands above will only generate the `android_release.apk` and `android_source.zip` files.

To delete the generated artifacts, the following commands can be used:
```
cd platform/android/java
./gradlew cleanGodotTemplates
```
This commit is contained in:
fhuya
2019-09-22 22:23:59 -07:00
parent 2e065d8ad0
commit ef143447ad
2 changed files with 82 additions and 34 deletions

View File

@@ -5,8 +5,6 @@ dependencies {
}
def pathToRootDir = "../../../../"
// Note: Only keep the abis you support to speed up the gradle 'assemble' task.
def supportedAbis = ["armv7", "arm64v8", "x86", "x86_64"]
android {
compileSdkVersion versions.compileSdk
@@ -56,27 +54,20 @@ android {
// files is only setup for editing support.
gradle.startParameter.excludedTaskNames += taskPrefix + "externalNativeBuild" + buildType
// Create tasks to generate the Godot native libraries.
def taskName = "compileGodotNativeLibs" + buildType
def releaseTarget = "release"
if (buildType == "Debug") {
releaseTarget += "_debug"
def releaseTarget = supportedTargets[buildType.toLowerCase()]
if (releaseTarget == null || releaseTarget == "") {
throw new GradleException("Invalid build type: " + buildType)
}
def abiTaskNames = []
// Creating gradle tasks to generate the native libraries for the supported abis.
supportedAbis.each { abi ->
def abiTaskName = taskName + abi.capitalize()
abiTaskNames += abiTaskName
tasks.create(name: abiTaskName, type: Exec) {
executable "scons"
args "--directory=${pathToRootDir}", "platform=android", "target=${releaseTarget}", "android_arch=${abi}"
}
if (!supportedAbis.contains(defaultAbi)) {
throw new GradleException("Invalid default abi: " + defaultAbi)
}
// Creating gradle task to run all of the previously generated tasks.
tasks.create(name: taskName, type: GradleBuild) {
tasks = abiTaskNames
// 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
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.