Files
kryon/tests/android_surface_test.py
waozi 3627ea8a90 Remove raylib from Kryon
Kryon carries no raylib code. The ten raylib host modules, the raylib
ZX player, the raylib audio sink and media provider, their tests and
docs, mk/raylib-library.mk, mk/zx-raylib.mk, mk/raylib-shell.html,
cmake/renderer-artifact, the renderer-raylib artifact, the
`backend = "raylib"` profile and [dependencies.raylib] are gone.
Desktop, Android and Canvas hosts keep the shared image, shader and
audio coverage. Browser asset and PCM audio play through
media_audio_web on the Canvas WebAudio engine; native audio uses
Ziran's core audio modules through media_audio_desktop.

macOS CI builds the desktop ZX player and checks the headless bundle
with it. The toolchain moves to Ziran 7fbc8152, which carries the
optimizer fixes the tree-input test needs. All 99 example locks are
regenerated as CI resolves them, without raylib.
2026-11-17 20:59:37 -03:00

52 lines
2.7 KiB
Python

#!/usr/bin/env python3
"""Verify Android viewport policy and native surface updates without a display."""
import os
from pathlib import Path
import shutil
import subprocess
from toolchain import BIN, ZIRAN_ROOT as ZIRAN
ROOT = Path(__file__).resolve().parents[1]
WORK = ROOT / "build/android-surface-check"
GEN = WORK / "native"
shutil.rmtree(GEN, ignore_errors=True)
GEN.mkdir(parents=True, exist_ok=True)
environment = dict(os.environ)
for name in ("DISPLAY", "WAYLAND_DISPLAY", "XAUTHORITY", "GDK_DISPLAY", "DBUS_SESSION_BUS_ADDRESS", "SESSION_MANAGER"):
environment.pop(name, None)
environment["YUE_DESKTOP_RECOVERY"] = "0"
def run(arguments, **options):
return subprocess.run(list(map(str, arguments)), env=environment, check=True, **options)
run([BIN / "ziran", "build", "--project", "--module-path", ROOT / "tests", "--target=c", "--no-main",
"--define", "ANDROID_BUILD", "--entry", "android_surface_behavior:main",
"--root", ROOT / "tests", "-o", GEN, ROOT / "tests/android_surface_behavior.zi"])
files = sorted(GEN.rglob("*.c"))
includes = ["-I" + str(ZIRAN / "include"), "-I" + str(GEN)]
includes += ["-I" + str(path) for path in sorted({p.parent for p in GEN.rglob("*.h")})]
run([os.environ.get("CC", "cc"), "-std=c11", "-Wall", "-Wextra", "-Werror",
"-Wno-unused-function", "-pthread", "-ffunction-sections", "-fdata-sections",
"-Wl,--gc-sections", *includes, *files, "-lm", "-o", WORK / "native-test"])
run([WORK / "native-test"])
run([BIN / "ziran", "bundle", "--project", "--module-path", ROOT / "tests", "--root", ROOT / "tests", "--entry", "android_viewport_policy:PolicyCheck",
"-o", WORK / "policy.zx", ROOT / "tests/android_viewport_policy.zi"])
result = run([BIN / "ziran", "run", WORK / "policy.zx"], capture_output=True, text=True)
assert result.stdout.strip() == "42", result.stdout
# Validate generated current native-surface code on every supported Android ABI.
# The old private desktop CORE.Window prefix is no longer part of this API.
ndk_base = Path(os.environ.get("ANDROID_HOME", str(Path.home() / "Android/Sdk"))) / "ndk"
ndks = sorted(ndk_base.glob("*/toolchains/llvm/prebuilt/linux-x86_64"))
if ndks:
clang = ndks[-1] / "bin/clang"
for target in ("aarch64-linux-android24", "armv7a-linux-androideabi24", "i686-linux-android24", "x86_64-linux-android24"):
for file in files:
run([clang, "--target=" + target, "-std=c11", "-fsyntax-only", *includes, file])
print(target + " current native surface generation passed", flush=True)
else:
print("Android NDK unavailable; cross ABI checks skipped")
print("Android viewport policy, native surface rotation/transform/pixels, and available four-ABI checks passed")