diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml index 5937e13..585524a 100644 --- a/.github/workflows/verify.yaml +++ b/.github/workflows/verify.yaml @@ -48,8 +48,10 @@ jobs: with: name: clayterm-wasm path: | - clayterm.wasm - wasm.ts + layout.wasm + input.wasm + layout.wasm.ts + input.wasm.ts test-alt-os: needs: test diff --git a/.gitignore b/.gitignore index 30f5beb..efab0a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ /.agent-shell/ -/clayterm-layout.wasm -/clayterm-input.wasm -/wasm-layout.ts -/wasm-input.ts +/layout.wasm +/input.wasm +/layout.wasm.ts +/input.wasm.ts /build/ /node_modules/ diff --git a/BUILD.md b/BUILD.md index e80e478..1b542e7 100644 --- a/BUILD.md +++ b/BUILD.md @@ -18,10 +18,12 @@ The local source build is driven by `make`. It generates: -- `clayterm.wasm` — the compiled WebAssembly module built from the C sources -- `wasm.ts` — a generated TypeScript file derived from `clayterm.wasm` +- `layout.wasm` — the layout WebAssembly module built from the C sources +- `input.wasm` — the input WebAssembly module built from the C sources +- `layout.wasm.ts` — generated TypeScript derived from `layout.wasm` +- `input.wasm.ts` — generated TypeScript derived from `input.wasm` -`wasm.ts` is generated output, not hand-maintained source. +These `.ts` files are generated output, not hand-maintained source. ## Clone the repo with submodules @@ -184,8 +186,10 @@ make This should produce: -- `clayterm.wasm` -- `wasm.ts` +- `layout.wasm` +- `input.wasm` +- `layout.wasm.ts` +- `input.wasm.ts` For a clean rebuild: @@ -199,7 +203,7 @@ Re-run `make` when: - you change files under `src/` - you update the `clay` submodule -- `clayterm.wasm` or `wasm.ts` is missing +- `layout.wasm`, `input.wasm`, `layout.wasm.ts`, or `input.wasm.ts` is missing - generated outputs look stale after switching branches or pulling changes When in doubt, use a clean rebuild: @@ -249,7 +253,7 @@ make clean && make Symptoms may include: - target-related `clang` errors mentioning `wasm32` -- linker failures while producing `clayterm.wasm` +- linker failures while producing the `.wasm` outputs Recovery: @@ -270,8 +274,8 @@ If the smoke test fails, fix the toolchain first and only then rerun `make`. Symptoms may include: -- `clayterm.wasm` is missing -- `wasm.ts` is missing +- `layout.wasm` or `input.wasm` is missing +- `layout.wasm.ts` or `input.wasm.ts` is missing - you changed `src/` or updated `clay/`, but the generated outputs do not match Recovery: diff --git a/Makefile b/Makefile index 3919b5b..c9713f9 100644 --- a/Makefile +++ b/Makefile @@ -50,23 +50,23 @@ INPUT_LDFLAGS = $(LDFLAGS_COMMON) \ DEPS = $(wildcard src/*.c src/*.h) -all: clayterm-layout.wasm clayterm-input.wasm wasm-layout.ts wasm-input.ts - @echo "Built clayterm-layout.wasm ($$(wc -c < clayterm-layout.wasm) bytes raw, $$(gzip -c clayterm-layout.wasm | wc -c) bytes gzip)" - @echo "Built clayterm-input.wasm ($$(wc -c < clayterm-input.wasm) bytes raw, $$(gzip -c clayterm-input.wasm | wc -c) bytes gzip)" +all: layout.wasm input.wasm layout.wasm.ts input.wasm.ts + @echo "Built layout.wasm ($$(wc -c < layout.wasm) bytes raw, $$(gzip -c layout.wasm | wc -c) bytes gzip)" + @echo "Built input.wasm ($$(wc -c < input.wasm) bytes raw, $$(gzip -c input.wasm | wc -c) bytes gzip)" -clayterm-layout.wasm: $(DEPS) +layout.wasm: $(DEPS) $(CC) $(CFLAGS) $(LAYOUT_LDFLAGS) -o $@ src/module-layout.c -clayterm-input.wasm: $(DEPS) +input.wasm: $(DEPS) $(CC) $(filter-out -DCLAY_IMPLEMENTATION -DCLAY_WASM, $(CFLAGS)) $(INPUT_LDFLAGS) -o $@ src/module-input.c -wasm-layout.ts: clayterm-layout.wasm - deno run --allow-read --allow-write tasks/bundle-wasm.ts clayterm-layout.wasm wasm-layout.ts +layout.wasm.ts: layout.wasm + deno run --allow-read --allow-write tasks/bundle-wasm.ts layout.wasm layout.wasm.ts -wasm-input.ts: clayterm-input.wasm - deno run --allow-read --allow-write tasks/bundle-wasm.ts clayterm-input.wasm wasm-input.ts +input.wasm.ts: input.wasm + deno run --allow-read --allow-write tasks/bundle-wasm.ts input.wasm input.wasm.ts clean: - rm -f clayterm.wasm clayterm-layout.wasm clayterm-input.wasm wasm.ts wasm-layout.ts wasm-input.ts + rm -f layout.wasm input.wasm layout.wasm.ts input.wasm.ts .PHONY: all clean diff --git a/input-native.ts b/input-native.ts index 34272b0..11576c9 100644 --- a/input-native.ts +++ b/input-native.ts @@ -169,7 +169,7 @@ export interface InputNative { delay(st: number): number; } -import { compiled } from "./wasm-input.ts"; +import { compiled } from "./input.wasm.ts"; export async function createInputNative( escLatency: number, diff --git a/tasks/bundle-wasm.ts b/tasks/bundle-wasm.ts index 2cad7e8..bd32feb 100644 --- a/tasks/bundle-wasm.ts +++ b/tasks/bundle-wasm.ts @@ -27,7 +27,11 @@ function encodeZ85(data: Uint8Array): string { return out.join(""); } -const [input = "clayterm.wasm", output = "wasm.ts"] = Deno.args; +const [input, output] = Deno.args; +if (!input || !output) { + console.error("Usage: bundle-wasm.ts "); + Deno.exit(1); +} const wasm = await Deno.readFile(input); diff --git a/term-native.ts b/term-native.ts index 0d94f52..37a8b7f 100644 --- a/term-native.ts +++ b/term-native.ts @@ -48,7 +48,7 @@ export interface Native { errorMessage(ct: number, index: number): string; } -import { compiled } from "./wasm-layout.ts"; +import { compiled } from "./layout.wasm.ts"; export async function createTermNative( w: number,