Skip to content

Commit 9c10612

Browse files
committed
Move Android NDK env setup before templating
When cross-building for Android, set NDK-related environment variables (NDK_ROOT, NDK_SYSROOT, ANDROID_ABI, ANDROID_API_LEVEL, HOST_TRIPLET) before performing env value templating so formatted values can reference them. Removes the duplicated Android env block that previously ran after templating.
1 parent 6c5b8fb commit 9c10612

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/forge/build.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,16 @@ def compile_env(self, **kwargs) -> dict[str, str]:
423423
}
424424
env.update(kwargs)
425425

426+
if self.cross_venv.sdk == "android":
427+
cc_parts = cc.split("/")
428+
env["NDK_ROOT"] = "/".join(cc_parts[: cc_parts.index("toolchains")])
429+
env["NDK_SYSROOT"] = str(
430+
ndk_sysroot or (Path(cc).parent.parent / "sysroot")
431+
)
432+
env["ANDROID_ABI"] = self.cross_venv.arch
433+
env["ANDROID_API_LEVEL"] = str(self.cross_venv.sdk_version)
434+
env["HOST_TRIPLET"] = self.cross_venv.platform_triplet
435+
426436
script_vars = {
427437
**env,
428438
**self.cross_venv.scheme_paths,
@@ -437,15 +447,6 @@ def compile_env(self, **kwargs) -> dict[str, str]:
437447
else:
438448
env[key] = str(value).format(**script_vars)
439449

440-
if self.cross_venv.sdk == "android":
441-
cc_parts = cc.split("/")
442-
env["NDK_ROOT"] = "/".join(cc_parts[: cc_parts.index("toolchains")])
443-
env["NDK_SYSROOT"] = str(
444-
ndk_sysroot or (Path(cc).parent.parent / "sysroot")
445-
)
446-
env["ANDROID_ABI"] = self.cross_venv.arch
447-
env["HOST_TRIPLET"] = self.cross_venv.platform_triplet
448-
449450
# Add in some user environment keys that are useful
450451
for key in [
451452
"TMPDIR",

0 commit comments

Comments
 (0)