Files
plot/scripts/generate-codec.py
waozi 2e06dfe503 Portable bundles draw band charts through their host
A bundle that shows values against a good range could not draw a band
chart, because the chart measures and paints with Kryon's native modules.
The chart's records move to band_chart_props, a bundle built with
KRYON_HOSTED_UI submits the chart as BandChartHostedHost, and a host answers
it with BandChartHostCall from band_chart_host, which decodes the records
with a codec generated on top of Kryon's widget codec. The check builds the
bundles as ZX, which the toolchain now runs.
2026-10-24 20:17:44 -03:00

29 lines
1.4 KiB
Python
Executable File

#!/usr/bin/env python3
"""Generate src/band_chart_codec.zi with Kryon's widget codec generator.
A portable bundle submits a band chart's records to its host, which decodes
them with this codec on top of Kryon's own widget codec. Pass --check to
verify the file is current."""
from pathlib import Path
import subprocess
import sys
ROOT = Path(__file__).resolve().parent.parent
KRYON = Path(subprocess.run(['ziran', 'pkg', 'path', 'kryon'], cwd=ROOT, check=True,
capture_output=True, text=True).stdout.strip())
command = [sys.executable, str(KRYON / 'scripts/generate-widget-codecs.py'),
'--output', str(ROOT / 'src/band_chart_codec.zi'),
'--uses', str(KRYON / 'src/backend/widget_codec.zi'),
'--source', str(KRYON / 'src/ui/geometry.zi'),
'--source', str(KRYON / 'src/ui/drawing_props.zi'),
'--source', str(ROOT / 'src/band_chart_props.zi'),
'--generated-by', 'scripts/generate-codec.py']
for root in ('BandChartProps', 'BandChartPoint', 'BandChartBand', 'BandChartResult'):
command += ['--root', root]
for line in ('"std/bundle_host"', '"std/byte_text_linux"', '"kryon/hosted_values"',
'"kryon/widget_codec"', '"kryon/geometry"', '"kryon/drawing_props"',
'"band_chart_props"'):
command += ['--import', line]
command += sys.argv[1:]
sys.exit(subprocess.run(command).returncode)