Files
breeze/scripts/generate-android-sources.py
T
waoziandClaude Opus 5.5 054a29f02c Remove raylib: run every host on Kryon and Ziran
Breeze builds and runs with no raylib anywhere, on Ziran 7fbc8152 and
Kryon b5a61b37, with plot, entity, apps, css and game2d pinned to that
Kryon, so the lock has one Kryon and no raylib package.

- Linux and Windows run on Kryon's SDL2 and Cairo desktop host; WebP
  decodes with the linked libwebp (KRYON_WEBP_LINKED).
- Android owns its NativeActivity loop on Kryon's android_runtime:
  Pixmap on the activity's surface, android_touch input and Android's
  typefaces, paced to the app's frame target. The CMake build drops
  breeze_raylib, GLES and the raylib link wraps, and links Kryon's fopen
  wrapper.
- The browser reaches Kryon's canvas modules directly.
- Audio is Ziran's std audio: its mixer, the SDL, AAudio and OpenSL ES
  sinks, the WAV, MP3 and Vorbis decoders and the audio package's Opus.
  The MP3 and Vorbis archives come from Ziran's own codec recipes. The
  browser keeps Kryon's Web Audio.
- Host modules choose the desktop host, Android, the canvas or, for
  native tests that select none, a headless host with no window, input
  or audio device. host_keys.zi and text_input_host.zi replace
  raylib_host.zi and raylib_text_input.zi; the log is one implementation,
  with logcat on Android and the C runtime's open flags on Windows.
- The Makefile, Click packaging, CI and release workflows build no raylib.
- Tests: radio, app log, asset files, DPI, legacy sessions, sync recovery
  and the Android JNI bridge run without raylib stubs; voice playback is
  a Ziran test of real Ogg Opus narration through Ziran's mixer. Tests
  that only exercised raylib internals are removed.
- AppsControllerSha256 is the controller built from Apps b96d9afe on
  this graph.

Local tests: Linux desktop window, Habits UI and the Ziran and native
tests above pass on a private Xvfb; the Android debug APK runs on a
Pixel 4a; the Windows package runs under Wine on a private Xvfb.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 13:16:23 -03:00

84 lines
3.9 KiB
Python

#!/usr/bin/env python3
"""Generate the complete checked Zi graph and its CMake source manifest."""
import argparse
import os
from pathlib import Path
import shutil
import subprocess
parser = argparse.ArgumentParser()
parser.add_argument("--compiler", type=Path, required=True)
parser.add_argument("--root", type=Path, required=True)
parser.add_argument("--kryon", type=Path, required=True)
parser.add_argument("--output", type=Path, required=True)
parser.add_argument("--manifest", type=Path, required=True)
parser.add_argument("--define", action="append", default=[])
args = parser.parse_args()
root = args.root.resolve()
kryon = args.kryon.resolve()
sources = sorted((root / "src").rglob("*.zi"))
sources.append(root / "apps/practice/hold_reminder.zi")
# Kryon's Android link wraps fopen; its wrapper serves relative names from the
# APK's assets and is a host root of its own, as Kryon's generator adds it.
sources.append(kryon / "src/backend/android_fopen.zi")
if list((root / "src").rglob("*.c")) or list((root / "src").rglob("*.kry")):
raise SystemExit("Android application implementation must be current Zi")
# The compiler writes every file anew. Outputs with the same bytes as before
# get their earlier times back, so the native build recompiles only changes.
previous = args.output.with_name(args.output.name + ".previous")
if previous.exists():
shutil.rmtree(previous)
if args.output.exists():
args.output.rename(previous)
args.output.mkdir(parents=True)
command = ["sh", str(root / "scripts/run-ziran.sh"), str(args.compiler),
"build", "--target=c", "--no-main", "--project", "--offline",
"--root", str(root)]
for name in args.define:
command.extend(["--define", name])
# Ziran selects platform code by its target, not by C preprocessor defines:
# name Android and the ABI's CPU so the standard library takes its Bionic
# branches instead of the host's glibc ones, as Kryon's generator does.
cpu_defines = {
"__aarch64__": "arm64",
"__x86_64__": "x64",
"__arm__": "none",
"__i386__": "none",
}
target_cpus = {cpu_defines[name] for name in args.define if name in cpu_defines}
if len(target_cpus) != 1:
parser.error("select exactly one Android CPU define (__aarch64__, __arm__, __x86_64__ or __i386__)")
command.extend(["--target-os", "android", "--target-cpu", target_cpus.pop()])
command.extend(["-o", str(args.output)])
command.extend(str(path.relative_to(root)) if path.is_relative_to(root) else str(path)
for path in sources)
completed = subprocess.run(command, cwd=root)
if completed.returncode != 0:
# The compiler already printed precise diagnostics; avoid repeating the
# entire application source list inside a Python exception traceback.
raise SystemExit(completed.returncode)
for output in args.output.rglob("*"):
earlier = previous / output.relative_to(args.output)
if output.is_file() and earlier.is_file() and output.read_bytes() == earlier.read_bytes():
times = earlier.stat()
os.utime(output, ns=(times.st_atime_ns, times.st_mtime_ns))
if previous.exists():
shutil.rmtree(previous)
outputs = sorted(args.output.rglob("*.c"))
if not outputs:
raise SystemExit("Zi compiler emitted no Android native sources")
headers = sorted(args.output.rglob("*.h"))
include_dirs = sorted({args.output, args.output / "src", *(p.parent for p in headers)})
lines = ["# Generated from the complete Zi import graph.", "set(APP_ZIRAN_GENERATED_SOURCES"]
lines.extend(f' "{path}"' for path in outputs)
lines.extend([")", "set(APP_ZIRAN_GENERATED_HEADERS"])
lines.extend(f' "{path}"' for path in headers)
lines.extend([")", "set(APP_ZIRAN_INCLUDE_DIRS"])
lines.extend(f' "{path}"' for path in include_dirs)
lines.append(")\n")
content = "\n".join(lines)
args.manifest.parent.mkdir(parents=True, exist_ok=True)
if not args.manifest.exists() or args.manifest.read_text() != content:
args.manifest.write_text(content)
print(f"Generated {len(outputs)} Android C outputs from maintained Zi sources")