diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2023-05-22 09:56:39 +0200 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2023-12-13 00:27:57 +0100 |
commit | 18152ac3a1d00d81d758425f2b67d37b60b56ab3 (patch) | |
tree | 5dfe4184589e899fdae6e36c13debeb68753aa7a | |
parent | 84692c6252438393999c427bf7f5d35b9c43926c (diff) | |
download | redot-engine-18152ac3a1d00d81d758425f2b67d37b60b56ab3.tar.gz |
Add `generate_apk=yes` to generate an APK after building
This is useful to speed up iteration when working on the engine
(or editor).
This can be combined with a script that calls `adb` to deploy the APK
on a device (coupled with Godot's `--export-*` for projects)
to further speed up iteration.
-rw-r--r-- | SConstruct | 1 | ||||
-rw-r--r-- | platform/android/SCsub | 28 |
2 files changed, 29 insertions, 0 deletions
diff --git a/SConstruct b/SConstruct index 534d5bd95d..978505977e 100644 --- a/SConstruct +++ b/SConstruct @@ -182,6 +182,7 @@ opts.Add(BoolVariable("debug_symbols", "Build with debugging symbols", False)) opts.Add(BoolVariable("separate_debug_symbols", "Extract debugging symbols to a separate file", False)) opts.Add(EnumVariable("lto", "Link-time optimization (production builds)", "none", ("none", "auto", "thin", "full"))) opts.Add(BoolVariable("production", "Set defaults to build Godot for use in production", False)) +opts.Add(BoolVariable("generate_apk", "Generate an APK/AAB after building Android library by calling Gradle", False)) # Components opts.Add(BoolVariable("deprecated", "Enable compatibility code for deprecated and removed features", True)) diff --git a/platform/android/SCsub b/platform/android/SCsub index dfc921cc54..97262cf148 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -1,5 +1,7 @@ #!/usr/bin/env python +import subprocess + Import("env") android_files = [ @@ -77,3 +79,29 @@ if lib_arch_dir != "": str(env["ANDROID_NDK_ROOT"]) + "/sources/cxx-stl/llvm-libc++/libs/" + lib_arch_dir + "/libc++_shared.so" ) env_android.Command(out_dir + "/libc++_shared.so", stl_lib_path, Copy("$TARGET", "$SOURCE")) + + def generate_apk(target, source, env): + if env["target"] != "editor" and env["dev_build"]: + subprocess.run( + [ + "./gradlew", + "generateDevTemplate", + "--quiet", + ], + cwd="platform/android/java", + ) + else: + # Android editor with `dev_build=yes` is handled by the `generateGodotEditor` task. + subprocess.run( + [ + "./gradlew", + "generateGodotEditor" if env["target"] == "editor" else "generateGodotTemplates", + "--quiet", + ], + cwd="platform/android/java", + ) + + if env["generate_apk"]: + generate_apk_command = env_android.Command("generate_apk", [], generate_apk) + command = env_android.AlwaysBuild(generate_apk_command) + env_android.Depends(command, [lib]) |