Files
kryon/scripts/build_android_runtime.py
waozi 9c80f79110 Build Android runtimes with the host zi2c
build_android_runtime.py ran Ziran's make with the NDK compiler and no
GEN_ZI2C, so the generated-C step would run a zi2c built for the device.
It now passes the pinned toolchain's build/bin/zi2c, which the Android
CMake already requires. The ZX player APK builds for all three ABIs and
runs app.zx natively on the Moto (armeabi-v7a).
2026-11-16 04:10:17 -03:00

36 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Build the pinned Ziran host runtime (libziran.a) for an Android target."""
import argparse
import os
from pathlib import Path
import subprocess
p = argparse.ArgumentParser()
p.add_argument("--source", type=Path, required=True)
p.add_argument("--output", type=Path, required=True)
p.add_argument("--cc", required=True)
p.add_argument("--ar", default="ar")
p.add_argument("--objcopy", default="objcopy")
p.add_argument("--flags", default="-O2 -fPIC")
a = p.parse_args()
source = a.source.resolve()
output = a.output.resolve()
command = [
"/usr/bin/make" if os.environ.get("HARMONY_BUILD_OWNER") else "make",
"-j4",
"-C",
str(source),
"BUILD_DIR=" + str(output),
"CC=" + a.cc,
"AR=" + a.ar,
"OBJCOPY=" + a.objcopy,
# The modules Ziran generates C for compile on this host, with the
# pinned toolchain's own zi2c, not one built for the device.
"GEN_ZI2C=" + str(source / "build/bin/zi2c"),
"CFLAGS=" + a.flags,
"FRAMEFLAGS=-Wframe-larger-than=16384",
str(output / "libziran.a"),
]
subprocess.run(command, check=True)