Skip to content

Commit

Permalink
Merge pull request #1291 from m4gr3d/update_android_logic_to_retrieve…
Browse files Browse the repository at this point in the history
…_ndk_toolchain

Update the environment variables used to access the Android NDK toolchain
  • Loading branch information
dsnopek authored Nov 3, 2023
2 parents c1196a1 + 86dbd5f commit e4eee8b
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions tools/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,32 @@ def options(opts):
"18" if "32" in ARGUMENTS.get("arch", "arm64") else "21",
)
opts.Add(
"ANDROID_NDK_ROOT",
"Path to your Android NDK installation. By default, uses ANDROID_NDK_ROOT from your defined environment variables.",
os.environ.get("ANDROID_NDK_ROOT", None),
"ANDROID_HOME",
"Path to your Android SDK installation. By default, uses ANDROID_HOME from your defined environment variables.",
os.environ.get("ANDROID_HOME", os.environ.get("ANDROID_SDK_ROOT")),
)


def exists(env):
return "ANDROID_NDK_ROOT" in os.environ or "ANDROID_NDK_ROOT" in ARGUMENTS
return get_android_ndk_root(env) is not None


# This must be kept in sync with the value in https://github.com/godotengine/godot/blob/master/platform/android/detect.py#L58.
def get_ndk_version():
return "23.2.8568313"


def get_android_ndk_root(env):
if env["ANDROID_HOME"]:
return env["ANDROID_HOME"] + "/ndk/" + get_ndk_version()
else:
return os.environ.get("ANDROID_NDK_ROOT")


def generate(env):
if "ANDROID_NDK_ROOT" not in env:
if get_android_ndk_root(env) is None:
raise ValueError(
"To build for Android, ANDROID_NDK_ROOT must be defined. Please set ANDROID_NDK_ROOT to the root folder of your Android NDK installation."
"To build for Android, the path to the NDK must be defined. Please set ANDROID_HOME to the root folder of your Android SDK installation."
)

if env["arch"] not in ("arm64", "x86_64", "arm32", "x86_32"):
Expand All @@ -42,7 +54,7 @@ def generate(env):
api_level = 21

# Setup toolchain
toolchain = env["ANDROID_NDK_ROOT"] + "/toolchains/llvm/prebuilt/"
toolchain = get_android_ndk_root(env) + "/toolchains/llvm/prebuilt/"
if sys.platform == "win32" or sys.platform == "msys":
toolchain += "windows"
import platform as pltfm
Expand Down

0 comments on commit e4eee8b

Please sign in to comment.