Files
breeze/scripts/generate-android-sources.py
T
waoziandClaude Opus 5.5 3b13f3d407 Fix habit spans and entries; judge habits against your average
- A tap on a running span's half-filled day opens it instead of ending
  it. Its end is picked there, set with Now, or cleared with the time
  picker's Clear so the span keeps running.
- Entries saved before entries existed open, edit and save again; their
  longer ids no longer fail to load.
- A habit linked to no practice no longer shows every practice's
  sessions.
- A span habit's time questions are its start and end, so the start is
  not asked twice; other habits' entries ask no time.
- Spans are good by their length, whenever they start: shorter or longer
  than your average, at least, at most or between hours and minutes.
- Number and time questions can be judged against your average; new ones
  start that way. Skip marks a day done without answers.
- Every change of a habit's settings is kept and synced, and each entry
  is judged by the goal it had then. Statistics charts shade the good
  range as it was each day, show a value's day and goal on hover or tap,
  and list the habit's changes.
- Lumi can set a span's good length and average goals.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-13 16:57:56 -03:00

63 lines
3.0 KiB
Python

#!/usr/bin/env python3
"""Generate the complete checked Zi graph and its CMake source manifest."""
import argparse
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"))
if list((root / "src").rglob("*.c")) or list((root / "src").rglob("*.kry")):
raise SystemExit("Android application implementation must be current Zi")
if args.output.exists():
shutil.rmtree(args.output)
args.output.mkdir(parents=True)
command = ["sh", str(root / "scripts/run-ziran.sh"), str(args.compiler),
"--no-main", "--root", str(root)]
for name in args.define:
command.extend(["--define", name])
for directory in (
root / "src", kryon / "src/ui", kryon / "src/backend", root / "build/packages/kss/src",
root / "build/packages/game2d/src", root / "build/packages/ziran/std", root / "build/packages/daochi-client",
):
command.extend(["--module-path", str(directory)])
# KSS imports Kryon as kryon/NAME, and account code imports oqs/Oqs.
command.extend(["--module-path", f"kryon={kryon / 'src/ui'}"])
command.extend(["--module-path", f"kryon={kryon / 'src/backend'}"])
command.extend(["--module-path", f"qrcode={root / 'build/packages/qrcode/src'}"])
command.extend(["--module-path", f"plot={root / 'build/packages/plot/src'}"])
command.extend(["--module-path", f"oqs={root / 'build/packages/oqs/src'}"])
command.extend(["-o", str(args.output)])
command.extend(str(path.relative_to(root)) 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)
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")