Files
rose-ash/hosts/ocaml/browser/build.sh
giles 0caa965de0
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 23m17s
OCaml CEK machine compiled to WebAssembly for browser execution
- wasm_of_ocaml compiles OCaml SX engine to WASM (722/722 spec tests)
- js_of_ocaml fallback also working (722/722 spec tests)
- Thin JS platform layer (sx-platform.js) with ~80 DOM/browser natives
- Lambda callback bridge: SX lambdas callable from JS via handle table
- Side-channel pattern bypasses js_of_ocaml return-value property stripping
- Web adapters (signals, deps, router, adapter-html) load as SX source
- Render mode dispatch: HTML tags + fragments route to OCaml renderer
- Island/component accessors handle both Component and Island types
- Dict-based signal support (signals.sx creates dicts, not native Signal)
- Scope stack implementation (collect!/collected/emit!/emitted/context)
- Bundle script embeds web adapters + WASM loader + platform layer
- SX_USE_WASM env var toggles WASM engine in dev/production
- Bootstrap extended: --web flag transpiles web adapters, :effects stripping

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 07:13:49 +00:00

38 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build the OCaml SX engine for browser use (WASM + JS fallback).
#
# Outputs:
# _build/default/browser/sx_browser.bc.wasm.js WASM loader
# _build/default/browser/sx_browser.bc.wasm.assets/ WASM modules
# _build/default/browser/sx_browser.bc.js JS fallback
#
# Usage:
# cd hosts/ocaml && ./browser/build.sh
set -euo pipefail
cd "$(dirname "$0")/.."
eval $(opam env 2>/dev/null || true)
echo "=== Building OCaml SX browser engine ==="
# Build all targets: bytecode, JS, WASM
dune build browser/sx_browser.bc.js browser/sx_browser.bc.wasm.js
echo ""
echo "--- Output sizes ---"
echo -n "JS (unoptimized): "; ls -lh _build/default/browser/sx_browser.bc.js | awk '{print $5}'
echo -n "WASM loader: "; ls -lh _build/default/browser/sx_browser.bc.wasm.js | awk '{print $5}'
echo -n "WASM modules: "; du -sh _build/default/browser/sx_browser.bc.wasm.assets/*.wasm | awk '{s+=$1}END{print s"K"}'
# Optimized JS build
js_of_ocaml --opt=3 -o _build/default/browser/sx_browser.opt.js _build/default/browser/sx_browser.bc
echo -n "JS (optimized): "; ls -lh _build/default/browser/sx_browser.opt.js | awk '{print $5}'
echo ""
echo "=== Build complete ==="
echo ""
echo "Test with:"
echo " node hosts/ocaml/browser/run_tests_js.js # JS"
echo " node --experimental-wasm-imported-strings hosts/ocaml/browser/run_tests_wasm.js # WASM"