Files
skiff/web/make_site.py
T
illuminus5 f956a125d6 Skiff Studio: the FM-1's screen in the Skiff Editor (a Screen tab), drawn by a copy of Skiff that follows the unit
The cast: while the editor watches, the FM-1 sends what its main loop and its audio interrupt take (16-byte records,
SysEx cmd 83, INFO 59 01), and a copy of Skiff in the browser does the same at the same moments, so it draws the unit's
screen with Skiff's own drawing code. There's no video: the FM-1's USB audio stays on, and it works in Chrome on
Android with the FM-1 plugged into a tablet. Checked on the unit with recordings replayed on the computer and in the
browser build: the music and the UI were the same in every once-a-second check, and the frames pixel for pixel except
where the screen draws the sound. The FM-1's HALL reverb comes out slightly differently from the computer build's (the
cause isn't known yet), so the scopes can differ by a few pixels. Not in a release yet: the released 2.5.1 has no cast,
so the tab needs the next release's firmware.

- firmware: cast.c (a ring of 64 records, sent between frames and between a draw's pieces; restart op 2: the music
  stored, the unit restarts and holds its splash until the cast starts, its music loaded before the audio ISR first
  runs, as the copy's) and its hooks (core.h CAST, CAST_BLOCK, CAST_READ): ui_input's takes, panel_enc's detents,
  keyboard_block's keys, events_block's MIDI and block count, a voice shed, the frame's readings, the draw's pieces
  and the scope's read, the LCD's pixels hashed, the editor's requests. FELUCCA_CAST is on in FM-1 builds (not the
  SMK-37's: its keybed, pads, faders and wheels aren't in it yet). Flash 580,988 B (576 B left), the ISR budgets as
  before. The MENU's CPU load is read once a frame (ui_cpu), as the copy gets it.
- web/emu/cast_follow.c, built by web/emu/build.sh as build/cast/felucca_cast.wasm: the copy, taking the records as
  they come (a frame once its e has come) and running the editor's requests at the unit's R through the unit's own
  editor.c. web/emu/cast_test.mjs feeds it a recording the same way.
- web/editor.html: the Screen tab (ja, en). Start: the editor's backup into the copy's flash, the cast's restart, the
  editor's own reconnect, then WATCH and CAST 1 first; every frame the editor sends after that goes to the copy too,
  so what the other tabs change, the copy changes. Link routes the records (onCast); INFO's 59 01 is info.cast.
  make_site.py puts the copy beside the editor.
- web/EDITOR_PROTOCOL.md: the Cast section. web/test_web.mjs: 10 tabs, scrLoaded in load()'s sandbox.
- tests/ui_test.c, tests/smk_ui_test.c: frame() takes the MENU's load as main.c now does.
2026-11-12 15:08:26 -06:00

142 lines
8.2 KiB
Python

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-only
# Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments
"""Make the site (GitHub Pages):
index.html redirect to the installer (the old URL keeps working)
firmware/skiff-VER.fwsc the package (+ LICENSE, LICENSING.md, LICENSES/: the package holds
JieLi SDK files under Apache-2.0, see LICENSING.md)
webapp/installer/index.html index_pkg.html, self-contained (fm1pkg.js, fm1ota.js, metadata inlined)
webapp/editor/index.html editor.html (+ fukiai.ttf, FUKIAI-LICENSE.txt; (2.0) conv/: conv.js and build/conv/conv.wasm,
the converter its Restore and the installer use; (Skiff Studio) felucca_cast.wasm, the
Screen tab's copy, from build/cast when web/emu/build.sh made it)
learn/ Learn Skiff, the manual in chapters (web/learn, without its local/ review videos)
try/ the browser emulator (build/emu from web/emu/build.sh, EMU_PREVIEW=0)
panel.js, fonts/ the panel's drawing and the fonts the Learn page shares, at the paths it has in web/
src/ not touched
web/make_site.py build/skiff-X.Y.fwsc X.Y OUT_DIR [SMK_PACKAGE ...]
The packages must be ones made by tools/fm1pkg_make.py (Felucca's own loader, no vendor files).
Their identities are read from them (FM-1_7xx, and for the SMK-37 builds SMK-37 Pro_7xx,
SMK-37 Elite_7xx, MKE-P37_7xx, one per model); the installer picks the one for the connected
model, and the device must report it after the install. Names: skiff-X.Y.fwsc (FM-1),
skiff-X.Y-smk37.fwsc, skiff-X.Y-smk37-elite.fwsc, skiff-X.Y-smk37-mke.fwsc.
"""
import json
import re
import shutil
import sys
from pathlib import Path
HERE = Path(__file__).resolve().parent
BLOCKS, BLK, KEEP = 20, 0x30, 0x2F
def strip_module(src):
src = re.sub(r"^export\s+", "", src, flags=re.M)
return re.sub(r"^import .*?;\n", "", src, flags=re.M)
def product_of(raw):
"""the package identity: one marker byte after each of the first 20 blocks (fm1pkg.js productOf)"""
return "".join(chr((m - i - 1) & 0xFF) for i in range(BLOCKS) if (m := raw[i * BLK + KEEP]) != 0x7D)
MODELS = {"FM-1": "", "SMK-37 Pro": "-smk37", "SMK-37 Elite": "-smk37-elite", "MKE-P37": "-smk37-mke"}
def package(path, version):
"""one of our packages -> (product, raw, published name); the model sets the name"""
raw = Path(path).read_bytes()
product = product_of(raw)
model, _, num = product.rpartition("_")
if model not in MODELS or not re.fullmatch(r"7\d\d", num):
raise SystemExit(f"{path}: identity {product!r} is not one of our packages "
f"(FM-1_7xx, SMK-37 Pro_7xx, SMK-37 Elite_7xx, MKE-P37_7xx)")
if b"FELUCCA-LOADER-1" not in raw: # Felucca loader marker: never publish a package with vendor files
raise SystemExit(f"{path}: no Felucca loader in it; the site ships only fm1pkg_make.py packages "
"(a package patched from an official one carries vendor files)")
return product, raw, f"skiff-{re.sub(r'[^A-Za-z0-9.-]', '-', version)}{MODELS[model]}.fwsc"
def main(pkg, version, out, *more):
out = Path(out)
pkgs = [package(p, version) for p in (pkg, *more)]
product, raw, name = pkgs[0]
if not product.startswith("FM-1_"):
raise SystemExit(f"{pkg}: the first package is the FM-1's (FM-1_7xx), not {product!r}")
models = [p.rpartition("_")[0] for p, _, _ in pkgs]
if len(set(models)) != len(models):
raise SystemExit(f"one package per model: {models}")
html = (HERE / "index_pkg.html").read_text(encoding="utf-8")
lib = strip_module((HERE / "fm1pkg.js").read_text(encoding="utf-8")) + "\n" + \
strip_module((HERE / "fm1ota.js").read_text(encoding="utf-8")) + "\n" + \
strip_module((HERE / "fm1backup.js").read_text(encoding="utf-8")) + "\n" + \
strip_module((HERE / "conv" / "conv.js").read_text(encoding="utf-8")) # ((2.0) its wasm: webapp/editor/conv/
conv = HERE.parent / "build" / "conv" / "conv.wasm" # ((2.0, Tier B 10) the converter: web/conv/build.sh's)
if not conv.exists():
raise SystemExit(f"{conv}: no converter build (sh web/conv/build.sh, after the release build)")
meta = json.dumps({"version": version, "product": product, "pkg": "../../firmware/" + name,
"packages": [{"product": p, "pkg": "../../firmware/" + n} for p, _, n in pkgs]})
for mark in ("/*LIB*/", "/*META*/"):
if html.count(mark) != 1:
raise SystemExit(f"index_pkg.html must contain {mark} once; update make_site.py")
html = html.replace("/*LIB*/", lib).replace("/*META*/", meta)
inst, ed, fw = out / "webapp" / "installer", out / "webapp" / "editor", out / "firmware"
for d in (inst, ed, fw):
d.mkdir(parents=True, exist_ok=True)
for old in fw.glob("skiff-*.fwsc"): # the current packages only
old.unlink()
(inst / "index.html").write_text(html, encoding="utf-8")
for _, data, n in pkgs:
(fw / n).write_bytes(data)
lic = HERE.parent / "LICENSES" # the package holds JieLi SDK files (Apache-2.0): their
(fw / "LICENSES").mkdir(exist_ok=True) # licence travels next to it, with Felucca's own
names = sorted(f.name for f in lic.glob("*.txt"))
for n in names:
shutil.copy(lic / n, fw / "LICENSES" / n)
(fw / "LICENSES" / "index.html").write_text( # the installer links this folder: Pages lists no folders
'<!doctype html><meta charset="utf-8"><title>Skiff licences</title><h1>Licence texts</h1><ul>'
+ "".join(f'<li><a href="{n}">{n}</a></li>' for n in names)
+ '</ul><p><a href="../LICENSING.md">LICENSING.md</a> · <a href="../LICENSE">LICENSE (GPL-3.0)</a></p>\n',
encoding="utf-8")
for doc in ("LICENSE", "LICENSING.md"):
shutil.copy(HERE.parent / doc, fw / doc)
shutil.copy(HERE / "editor.html", ed / "index.html")
for f in ("fukiai.ttf", "FUKIAI-LICENSE.txt", "fm1backup.js"):
if (HERE / f).exists():
shutil.copy(HERE / f, ed / f)
cast = HERE.parent / "build" / "cast" / "felucca_cast.wasm" # ((Skiff Studio) the Screen tab's copy: web/emu/build.sh's
if cast.exists():
shutil.copy(cast, ed / "felucca_cast.wasm")
(ed / "conv").mkdir(exist_ok=True) # ((2.0) the converter: the editor's Restore, the installer's write-back)
shutil.copy(HERE / "conv" / "conv.js", ed / "conv" / "conv.js")
shutil.copy(conv, ed / "conv" / "conv.wasm")
if (HERE / "fonts").is_dir(): # ((Skiff 1.0) the editor's Barlow Condensed, its OFL beside it)
shutil.copytree(HERE / "fonts", ed / "fonts", dirs_exist_ok=True,
ignore=shutil.ignore_patterns("InterTight*")) # (the Learn page's, not the editor's)
shutil.rmtree(out / "learn", ignore_errors=True) # ((Skiff) Learn Skiff: ../panel.js and ../fonts/, as in web/)
shutil.copytree(HERE / "learn", out / "learn", ignore=shutil.ignore_patterns("local"))
shutil.copy(HERE / "panel.js", out / "panel.js")
shutil.copytree(HERE / "fonts", out / "fonts", dirs_exist_ok=True)
emu = HERE.parent / "build" / "emu" # ((Skiff #18) the browser emulator: web/emu/build.sh's, ../panel.js)
page = (emu / "index.html").read_text(encoding="utf-8") if (emu / "index.html").exists() else ""
if f">v{version}<" not in page:
raise SystemExit(f"{emu}: no browser build of v{version} without the preview mark "
"(EMU_PREVIEW=0 sh web/emu/build.sh, after the release build)")
shutil.rmtree(out / "try", ignore_errors=True)
shutil.copytree(emu, out / "try")
(out / "index.html").write_text(
'<!doctype html><meta charset="utf-8"><title>Skiff</title>'
'<meta http-equiv="refresh" content="0; url=webapp/installer/">'
'<a href="webapp/installer/">Skiff installer</a>\n', encoding="utf-8")
print(f"site: {out}: webapp/installer ({len(html)} B), webapp/editor, learn, try, "
+ ", ".join(f"firmware/{n} ({len(d)} B, {p})" for p, d, n in pkgs))
if __name__ == "__main__":
if len(sys.argv) < 4:
sys.exit(__doc__)
main(*sys.argv[1:])