Build: stage the legacy core in the Play script rather than trusting jniLibs

The script bundled whatever core happened to be sitting in jniLibs, and
build-variants.sh overwrites that path once per variant, so the file left there
is simply whichever ran last. Running the variants and then rebuilding the
bundle would have shipped an armv8.2 core inside a minSdk 30 bundle:
installable on devices that cannot execute it, failing at dlopen, with nothing
in the failure to point at the cause.

Play serves one bundle to every device, so the ISA floor has to be the lowest
ARMSX3 supports. The legacy core is now stripped into place by this script
every time, and it refuses to run if that core has not been built.

The bundle already shipped was correct -- the legacy core was staged by hand
before it was built -- but only by hand, which is the part worth removing.
This commit is contained in:
jpolo1224
2026-08-20 12:18:23 -04:00
parent 05e4547f67
commit da26a45548
+23
View File
@@ -69,6 +69,29 @@ fi
# compressed per-class archive, and packageBundle demands a plain mapping.txt. ARMSX2 ships
# its Play build with minify off too, so this is the existing precedent rather than a new
# compromise.
# Stage the LEGACY core, and do not trust whatever happens to be in jniLibs.
#
# build-variants.sh writes each variant's core to the same path in turn, so the file left there
# is simply whichever variant ran last. A bundle built on top of that would ship an armv8.2 core
# with minSdk 30 -- installable on devices that cannot execute it, and failing at dlopen with
# nothing to explain why. Play serves one bundle to every device, so the ISA floor has to be the
# lowest one ARMSX3 supports.
CORE_SRC="$(cd "$HERE/.." && pwd)/build-legacy/android/libarmsx3-core.so"
JNI="$UI/app/src/main/jniLibs/arm64-v8a"
if [ ! -f "$CORE_SRC" ]; then
echo "FAIL: legacy core not built. Run: ninja -C build-legacy android/libarmsx3-core.so" >&2
exit 1
fi
NDK_DIR="$(ls -d "$ANDROID_HOME/ndk/"*/ 2>/dev/null | sort -V | tail -1)"
STRIP="${NDK_DIR}toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip"
[ -x "$STRIP" ] || { echo "FAIL: llvm-strip not found under $ANDROID_HOME/ndk" >&2; exit 1; }
echo "==> Staging the legacy core"
mkdir -p "$JNI"
"$STRIP" --strip-unneeded -o "$JNI/libarmsx3-core.so" "$CORE_SRC"
echo "==> Building Play bundle (minSdk $MIN_SDK, minify off)"
( cd "$UI" && ./gradlew --quiet :app:bundlePlayRelease "-Parmsx3.minSdk=$MIN_SDK" -Parmsx3.noMinify )