#!/usr/bin/env bash # Pack the simulated rig's page (led-simulator/web) and the drivers built to WebAssembly (led-simulator/web/wasm, # from `make sim-wasm`) into www_dist/sim.pack, which the host builds embed and serve at /sim/ # (sim-controller/components/sim/sim_rig.c). Same format as www.pack: "WWW1", then per file u16 name length, # u32 data length, name, gzipped data; a zero name length ends it. # Without the wasm the pack is empty, and /sim/ says how to build it. set -euo pipefail cd "$(dirname "$0")/.." SRC=led-simulator/web OUT=www_dist mkdir -p "$OUT" python3 - "$SRC" "$OUT/sim.pack" <<'PY' import gzip, os, struct, sys src, out_path = sys.argv[1], sys.argv[2] files = ["index.html", "app.js", "layout.js", "styles.css", "driver-worker.js", "gallery.html", "gallery.js", "gallery.css", "wasm/led_driver.mjs", "wasm/led_driver.wasm", "wasm/led_fx.mjs", "wasm/led_fx.wasm"] out = bytearray(b"WWW1") if not os.path.isfile(os.path.join(src, "wasm/led_driver.wasm")): print("sim.pack: no drivers built (make sim-wasm): the rig is left out") else: for name in files: data = gzip.compress(open(os.path.join(src, name), "rb").read(), 9, mtime=0) out += struct.pack("