Files
waozi ef0de86e02
Cloudflare Pages / Build and verify the site (push) Successful in 3m29s
Integrate Breeze desktop, Android, and app updates
Use the verified dependency lock across native hosts and bundled apps. Preserve saved styles, local app reactivation, and offline packages while integrating the latest practice, Habits, Lumi, and figure preview updates.
2026-11-20 02:24:34 -03:00

50 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""Build the reviewed Apps controller with its locked dependency graph."""
import argparse
from pathlib import Path
import shutil
import subprocess
import tempfile
ROOT = Path(__file__).resolve().parents[1]
def module_roots(manifest):
text = manifest.read_text()
try:
import tomllib
return tomllib.loads(text)['package']['module_roots']
except ModuleNotFoundError:
# Python before 3.11, as on the Ubuntu 22.04 package builders: the
# manifest keeps module_roots as one list of strings on one line.
import ast
import re
return ast.literal_eval(re.search(r'^module_roots\s*=\s*(\[[^\]]*\])', text, re.M).group(1))
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--ziran', type=Path, required=True)
parser.add_argument('--output', type=Path, required=True)
args = parser.parse_args()
# The host accepts the reviewed digest in every build. Compile the
# controller from the locked package graph, including on development hosts.
with tempfile.TemporaryDirectory(prefix='apps-lock-', dir=ROOT / 'build') as directory:
context = Path(directory)
for name in ('ziran.toml', 'ziran.lock'):
shutil.copyfile(ROOT / name, context / name)
# Ziran resolves a project only when its module roots exist; the
# controller needs none of this app's modules, so they stay empty.
for directory in module_roots(ROOT / 'ziran.toml'):
(context / directory).mkdir(parents=True, exist_ok=True)
package = Path(subprocess.check_output(
[str(args.ziran.resolve()), 'pkg', 'path', 'apps', '--locked'],
cwd=context, text=True).strip())
subprocess.run(['python3', str(package / 'scripts/build-ui.py'),
'--output', str(args.output.resolve()), '--project', str(context),
'--compiler', str(args.ziran.resolve())], cwd=ROOT, check=True)
if __name__ == '__main__':
main()