Compile the compositor to a wasm component, run by a small wasmtime host
CI / test (push) Failing after 22s

The whole compositor (Wayland server, window manager, scene, rasteriser, shell) now builds as
build/components/compositor.wasm: a component that imports only moonplasma:host/sys
(wit/host/sys.wit: sockets + SCM_RIGHTS, memfd, poll, spawn, files, clock) and exports run().
host-wasm/ is the native side: a wasmtime program implementing that interface with libc.

- compositor/sys: per-target backends (sys_native.mbt over the C shim, sys_wasm.mbt over the WIT
  imports) behind one API; wayland/nested/host/shell/scene/renderer/gfx build for wasm unchanged.
- compositor/app: the entry point (arg parsing + main loop) as a library for both targets;
  --serve keeps refreshing a PNG so a live compositor can be inspected without a display.
- compositor/font, compositor/wasm: wasm-side placeholders (bitmap font; no panel modules yet,
  since a component can't embed a second wasm runtime: that becomes a host import).
- scripts/gen-native-stubs.py: native stand-ins for wasm-only generated imports.
- just compositor-wasm / host-wasm / run-wasm.

Verified: foot connects to the component's socket and renders into it; native build and
tests unchanged (16/23, the same 7 need unbuilt panel modules).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Sonnet 5.5 committed 2026-11-25 01:41:31 -08:00
1 parent 92d2b29889
commit 6aba9b6a4f
42 files changed
+3163 -10

No files matched your search

@@ -0,0 +1,156 @@
// Generated by scripts/gen-native-stubs.py. Native stand-ins for the wasm-only ffi.mbt.
///|
fn wasmImportUnixListen(p0 : Int, p1 : Int) -> Int {
abort("wasm-only host import")
}
///|
fn wasmImportUnixAccept(p0 : Int) -> Int {
abort("wasm-only host import")
}
///|
fn wasmImportUnixConnect(p0 : Int, p1 : Int) -> Int {
abort("wasm-only host import")
}
///|
fn wasmImportCloseFd(p0 : Int) -> Unit {
abort("wasm-only host import")
}
///|
fn wasmImportUnlink(p0 : Int, p1 : Int) -> Unit {
abort("wasm-only host import")
}
///|
fn wasmImportPollRead(p0 : Int, p1 : Int) -> Int {
abort("wasm-only host import")
}
///|
fn wasmImportRecvmsg(p0 : Int, p1 : Int, p2 : Int) -> Unit {
abort("wasm-only host import")
}
///|
fn wasmImportSendmsg(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int {
abort("wasm-only host import")
}
///|
fn wasmImportMemfdCreate(p0 : Int, p1 : Int, p2 : Int) -> Int {
abort("wasm-only host import")
}
///|
fn wasmImportPwrite(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int {
abort("wasm-only host import")
}
///|
fn wasmImportMmapRead(p0 : Int, p1 : Int, p2 : Int) -> Unit {
abort("wasm-only host import")
}
///|
fn wasmImportReadFile(p0 : Int, p1 : Int, p2 : Int) -> Unit {
abort("wasm-only host import")
}
///|
fn wasmImportWriteFile(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int {
abort("wasm-only host import")
}
///|
fn wasmImportReadProc(p0 : Int, p1 : Int, p2 : Int) -> Unit {
abort("wasm-only host import")
}
///|
fn wasmImportMkdirP(p0 : Int, p1 : Int) -> Int {
abort("wasm-only host import")
}
///|
fn wasmImportListDesktopFiles(p0 : Int, p1 : Int, p2 : Int) -> Unit {
abort("wasm-only host import")
}
///|
fn wasmImportSleepMs(p0 : Int) -> Unit {
abort("wasm-only host import")
}
///|
fn wasmImportMonotonicMs() -> Int64 {
abort("wasm-only host import")
}
///|
fn wasmImportLog(p0 : Int, p1 : Int) -> Unit {
abort("wasm-only host import")
}
///|
fn wasmImportGetpid() -> Int {
abort("wasm-only host import")
}
///|
fn wasmImportWallTimeField(p0 : Int) -> Int {
abort("wasm-only host import")
}
///|
fn wasmImportGetenv(p0 : Int, p1 : Int, p2 : Int) -> Unit {
abort("wasm-only host import")
}
///|
fn wasmImportHasExe(p0 : Int, p1 : Int) -> Int {
abort("wasm-only host import")
}
///|
fn wasmImportSpawn(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int {
abort("wasm-only host import")
}
///|
fn mbt_ffi_str2ptr(str : String) -> Int {
abort("wasm-only")
}
///|
fn mbt_ffi_load32(offset : Int) -> Int {
abort("wasm-only")
}
///|
fn mbt_ffi_free(position : Int) -> Unit {
abort("wasm-only")
}
///|
fn mbt_ffi_malloc(size : Int) -> Int {
abort("wasm-only")
}
///|
fn mbt_ffi_ptr2bytes(ptr : Int, len : Int) -> FixedArray[Byte] {
abort("wasm-only")
}
///|
fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String {
abort("wasm-only")
}
///|
fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int {
abort("wasm-only")
}