Files
breeze/scripts/check-zi-sources.py
T
waozi 939593a1e6 Checkpoint media compression, narration, and app updates
Preserve current AVIF compression, local voice pipelines, practice workflows, UI API migration, locale updates, and packaging work. Native integration validation remains pending.
2026-11-10 22:20:31 -03:00

68 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""Check the complete Inbe Ziran program against its pinned libraries."""
import fcntl
import os
import shlex
from pathlib import Path
import subprocess
import sys
root = Path(__file__).resolve().parent.parent
compiler = Path(sys.argv[1]).resolve()
sources = sorted((root / "src").rglob("*.zi"))
sources.append(root / "apps/practice/hold_reminder.zi")
legacy = sorted((root / "src").rglob("*.kry"))
if legacy:
for path in legacy:
print(f"legacy source: {path.relative_to(root)}", file=sys.stderr)
sys.exit(1)
if not sources:
print("No Inbe .zi sources found", file=sys.stderr)
sys.exit(1)
target_defines = os.environ.get("ZI_CHECK_DEFINES", "PLATFORM_DESKTOP").split()
define_args = [part for name in target_defines for part in ("--define", name)]
(root / "build").mkdir(exist_ok=True)
compiler_lock = (root / "build/ziran-compiler.lock").open("a")
fcntl.flock(compiler_lock, fcntl.LOCK_EX)
result = subprocess.run(
[
str(compiler),
"check",
"--project",
"--offline",
*shlex.split(os.environ.get("PACKAGE_FLAGS", "")),
"--root",
".",
*define_args,
*(str(source.relative_to(root)) for source in sources),
],
cwd=root,
capture_output=True,
text=True,
check=False,
)
compiler_lock.close()
if result.returncode == 0:
print(f"Ziran checked {len(sources)} modules together: passed")
sys.exit(0)
diagnostics = result.stderr.strip().splitlines()
print(f"Ziran checked {len(sources)} modules together: failed", file=sys.stderr)
if not diagnostics:
print(f"Compiler exited with status {result.returncode} without a diagnostic",
file=sys.stderr)
else:
limit = len(diagnostics) if os.environ.get("ZI_CHECK_VERBOSE") == "1" else 30
for line in diagnostics[:limit]:
print(line, file=sys.stderr)
if len(diagnostics) > limit:
print(f"... {len(diagnostics) - limit} more diagnostic lines",
file=sys.stderr)
sys.exit(result.returncode if result.returncode > 0 else 1)