Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions android/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@ fi
if [ -z "${toolchain:-}" ] && [ -n "${NDK_HOME:-}" ]; then
toolchain=$(echo "$NDK_HOME"/toolchains/llvm/prebuilt/*)
fi
# 3.13+: CPython's in-tree Android tooling auto-resolves the NDK under
# $ANDROID_HOME/ndk/$cpython_ndk_version/ without ever exporting NDK_HOME,
# so neither of the branches above fires. Walk that path so normalize sees
# a non-empty build-time toolchain and the relocation block can substitute
# on consumer hosts.
if [ -z "${toolchain:-}" ] && [ -n "${ANDROID_HOME:-}" ] && [ -n "${cpython_ndk_version:-}" ]; then
candidate="$ANDROID_HOME/ndk/$cpython_ndk_version/toolchains/llvm/prebuilt"
if [ -d "$candidate" ]; then
toolchain=$(echo "$candidate"/*)
fi
fi

python3 "$script_dir/normalize_mobile_forge_install.py" "$PREFIX" \
--ndk-toolchain "${toolchain:-}"
11 changes: 9 additions & 2 deletions android/normalize_mobile_forge_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,17 @@ def _local_toolchain():
for _key, _value in tuple(build_time_vars.items()):
if not isinstance(_value, str):
continue
for _old_prefix in _install_prefixes:
_value = _value.replace(_old_prefix, _prefix)
# NDK substitution must run before install-prefix substitution: when
# the build-time NDK lives under one of `_install_prefixes` (e.g. the
# GitHub runner places NDK under `/usr/local/lib/android/sdk/ndk/...`),
# rewriting the prefix first would mangle the NDK string and leave
# nothing for the NDK rule to match. Swapping order keeps both rules
# independent: NDK fully resolves to the local toolchain, then any
# remaining install-prefix references get re-anchored.
if _build_ndk and _local_ndk:
_value = _value.replace(_build_ndk, _local_ndk)
for _old_prefix in _install_prefixes:
_value = _value.replace(_old_prefix, _prefix)
build_time_vars[_key] = _value


Expand Down
Loading