diff options
Diffstat (limited to 'platform/android/detect.py')
-rw-r--r-- | platform/android/detect.py | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/platform/android/detect.py b/platform/android/detect.py index 2860898e5c..fea8ec3287 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -6,7 +6,7 @@ import subprocess from typing import TYPE_CHECKING if TYPE_CHECKING: - from SCons import Environment + from SCons.Script.SConscript import SConsEnvironment def get_name(): @@ -21,13 +21,14 @@ def get_opts(): from SCons.Variables import BoolVariable return [ - ("ANDROID_SDK_ROOT", "Path to the Android SDK", get_env_android_sdk_root()), + ("ANDROID_HOME", "Path to the Android SDK", get_env_android_sdk_root()), ( "ndk_platform", 'Target platform (android-<api>, e.g. "android-' + str(get_min_target_api()) + '")', "android-" + str(get_min_target_api()), ), BoolVariable("store_release", "Editor build for Google Play Store (for official builds only)", False), + BoolVariable("generate_apk", "Generate an APK/AAB after building Android library by calling Gradle", False), ] @@ -41,17 +42,17 @@ def get_doc_path(): return "doc_classes" -# Return the ANDROID_SDK_ROOT environment variable. +# Return the ANDROID_HOME environment variable. def get_env_android_sdk_root(): - return os.environ.get("ANDROID_SDK_ROOT", -1) + return os.environ.get("ANDROID_HOME", os.environ.get("ANDROID_SDK_ROOT", "")) def get_min_sdk_version(platform): return int(platform.split("-")[1]) -def get_android_ndk_root(env): - return env["ANDROID_SDK_ROOT"] + "/ndk/" + get_ndk_version() +def get_android_ndk_root(env: "SConsEnvironment"): + return env["ANDROID_HOME"] + "/ndk/" + get_ndk_version() # This is kept in sync with the value in 'platform/android/java/app/config.gradle'. @@ -68,14 +69,15 @@ def get_flags(): return [ ("arch", "arm64"), # Default for convenience. ("target", "template_debug"), + ("supported", ["mono"]), ] # Check if Android NDK version is installed # If not, install it. -def install_ndk_if_needed(env): +def install_ndk_if_needed(env: "SConsEnvironment"): print("Checking for Android NDK...") - sdk_root = env["ANDROID_SDK_ROOT"] + sdk_root = env["ANDROID_HOME"] if not os.path.exists(get_android_ndk_root(env)): extension = ".bat" if os.name == "nt" else "" sdkmanager = sdk_root + "/cmdline-tools/latest/bin/sdkmanager" + extension @@ -87,7 +89,7 @@ def install_ndk_if_needed(env): else: print("Cannot find " + sdkmanager) print( - "Please ensure ANDROID_SDK_ROOT is correct and cmdline-tools are installed, or install NDK version " + "Please ensure ANDROID_HOME is correct and cmdline-tools are installed, or install NDK version " + get_ndk_version() + " manually." ) @@ -95,7 +97,7 @@ def install_ndk_if_needed(env): env["ANDROID_NDK_ROOT"] = get_android_ndk_root(env) -def configure(env: "Environment"): +def configure(env: "SConsEnvironment"): # Validate arch. supported_arches = ["x86_32", "x86_64", "arm32", "arm64"] if env["arch"] not in supported_arches: @@ -170,10 +172,6 @@ def configure(env: "Environment"): env["RANLIB"] = compiler_path + "/llvm-ranlib" env["AS"] = compiler_path + "/clang" - # Disable exceptions on template builds - if not env.editor_build: - env.Append(CXXFLAGS=["-fno-exceptions"]) - env.Append( CCFLAGS=( "-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing".split() @@ -204,7 +202,7 @@ def configure(env: "Environment"): env.Append(LIBS=["OpenSLES", "EGL", "android", "log", "z", "dl"]) if env["vulkan"]: - env.Append(CPPDEFINES=["VULKAN_ENABLED"]) + env.Append(CPPDEFINES=["VULKAN_ENABLED", "RD_ENABLED"]) if not env["use_volk"]: env.Append(LIBS=["vulkan"]) |