Skip to content

Commit 86dbd5f

Browse files
committed
Update the environment variables used to access the Android NDK toolchain
1 parent c1196a1 commit 86dbd5f

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

tools/android.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,32 @@ def options(opts):
1111
"18" if "32" in ARGUMENTS.get("arch", "arm64") else "21",
1212
)
1313
opts.Add(
14-
"ANDROID_NDK_ROOT",
15-
"Path to your Android NDK installation. By default, uses ANDROID_NDK_ROOT from your defined environment variables.",
16-
os.environ.get("ANDROID_NDK_ROOT", None),
14+
"ANDROID_HOME",
15+
"Path to your Android SDK installation. By default, uses ANDROID_HOME from your defined environment variables.",
16+
os.environ.get("ANDROID_HOME", os.environ.get("ANDROID_SDK_ROOT")),
1717
)
1818

1919

2020
def exists(env):
21-
return "ANDROID_NDK_ROOT" in os.environ or "ANDROID_NDK_ROOT" in ARGUMENTS
21+
return get_android_ndk_root(env) is not None
22+
23+
24+
# This must be kept in sync with the value in https://github.com/godotengine/godot/blob/master/platform/android/detect.py#L58.
25+
def get_ndk_version():
26+
return "23.2.8568313"
27+
28+
29+
def get_android_ndk_root(env):
30+
if env["ANDROID_HOME"]:
31+
return env["ANDROID_HOME"] + "/ndk/" + get_ndk_version()
32+
else:
33+
return os.environ.get("ANDROID_NDK_ROOT")
2234

2335

2436
def generate(env):
25-
if "ANDROID_NDK_ROOT" not in env:
37+
if get_android_ndk_root(env) is None:
2638
raise ValueError(
27-
"To build for Android, ANDROID_NDK_ROOT must be defined. Please set ANDROID_NDK_ROOT to the root folder of your Android NDK installation."
39+
"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."
2840
)
2941

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

4456
# Setup toolchain
45-
toolchain = env["ANDROID_NDK_ROOT"] + "/toolchains/llvm/prebuilt/"
57+
toolchain = get_android_ndk_root(env) + "/toolchains/llvm/prebuilt/"
4658
if sys.platform == "win32" or sys.platform == "msys":
4759
toolchain += "windows"
4860
import platform as pltfm

0 commit comments

Comments
 (0)