0.1.0-0-pre.11
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# file: scripts/build_android_rust.py
|
||||
# version: 2
|
||||
# version: 3
|
||||
|
||||
"""Build one Android Rust game entrypoint and stage SDL3 and Rust jniLibs."""
|
||||
|
||||
@@ -22,13 +22,18 @@ ABI_TO_TRIPLE = {
|
||||
}
|
||||
GAME_TO_MODULE = {"reflex": "game-reflex-poc", "snake": "game-snake-poc"}
|
||||
|
||||
def read_sdl3_aar_name(properties_path: pathlib.Path) -> str:
|
||||
"""Read the configured SDL3 AAR filename."""
|
||||
def read_gradle_property(properties_path: pathlib.Path, property_name: str) -> str:
|
||||
"""Read one required Android Gradle property."""
|
||||
prefix = f"{property_name}="
|
||||
for raw_line in properties_path.read_text(encoding="utf-8").splitlines():
|
||||
line = raw_line.strip()
|
||||
if line.startswith("sdl3AarName="):
|
||||
if line.startswith(prefix):
|
||||
return line.split("=", 1)[1].strip()
|
||||
raise RuntimeError("sdl3AarName is missing from Android/gradle.properties")
|
||||
raise RuntimeError(f"{property_name} is missing from Android/gradle.properties")
|
||||
|
||||
def read_sdl3_aar_name(properties_path: pathlib.Path) -> str:
|
||||
"""Read the configured SDL3 AAR filename."""
|
||||
return read_gradle_property(properties_path, "sdl3AarName")
|
||||
|
||||
def find_sdl3_member(archive: zipfile.ZipFile, abi: str) -> str:
|
||||
"""Return the SDL3 shared-library member for one Android ABI."""
|
||||
@@ -75,7 +80,9 @@ def main() -> int:
|
||||
parser.add_argument("--release", action="store_true")
|
||||
arguments = parser.parse_args()
|
||||
root = pathlib.Path(__file__).resolve().parent.parent
|
||||
aar_name = read_sdl3_aar_name(root / "Android" / "gradle.properties")
|
||||
properties_path = root / "Android" / "gradle.properties"
|
||||
aar_name = read_sdl3_aar_name(properties_path)
|
||||
ndk_version = read_gradle_property(properties_path, "androidNdkVersion")
|
||||
aar_path = root / "Android" / "libs" / aar_name
|
||||
if not aar_path.is_file():
|
||||
print(f"missing SDL3 AAR: {aar_path}", file=sys.stderr)
|
||||
@@ -90,6 +97,15 @@ def main() -> int:
|
||||
print(str(error), file=sys.stderr)
|
||||
return 2
|
||||
environment = os.environ.copy()
|
||||
android_home = environment.get("ANDROID_HOME")
|
||||
if not android_home:
|
||||
print("ANDROID_HOME is required to resolve the project NDK", file=sys.stderr)
|
||||
return 2
|
||||
ndk_home = pathlib.Path(android_home) / "ndk" / ndk_version
|
||||
if not ndk_home.is_dir():
|
||||
print(f"configured Android NDK is missing: {ndk_home}", file=sys.stderr)
|
||||
return 2
|
||||
environment["ANDROID_NDK_HOME"] = str(ndk_home)
|
||||
rustflags = environment.get("RUSTFLAGS", "").strip()
|
||||
link_flag = f"-L native={link_dir}"
|
||||
environment["RUSTFLAGS"] = f"{rustflags} {link_flag}".strip()
|
||||
|
||||
Reference in New Issue
Block a user