Files
chandra/justfile
T
nandiandClaude Sonnet 5.5 c03d4c6c17
CI / test (push) Failing after 1m13s
The wasm compositor as a login session: DRM/KMS + libinput through the host
New moonplasma:host/display import (open, poll, present, cursor, input events, close). The
wasmtime host implements it by compiling the compositor's own kms shim (libseat + DRM/KMS +
libinput + xkbcommon) via build.rs (feature drm, default on), so the native and wasm backends
share one implementation. compositor/kms gets a wasm backend with the same API, and the shared
app loop gains --drm.

- session: install.py installs the host, compositor.wasm, fonts, config, wit and modules and the
  display-manager entry (--native keeps the old native session); the launcher starts the host
  when installed. just run-drm / install-session use the wasm compositor; *-native keep the old.
- compositor.wasm moves to build/ (out of build/components, where the module catalog scans).

Verified: component builds with the new import, host instantiates it and renders frames, installed
layout (fonts/modules/theme from the share dir) renders correctly in a sandbox, native build and
tests unchanged. NOT exercised on a real login VT.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-25 02:38:19 -08:00

142 lines
6.2 KiB
Makefile

# moon-plasma tasks. `just` lists them.
set shell := ["bash", "-euo", "pipefail", "-c"]
export PATH := env_var('HOME') + "/.moon/bin:" + env_var('PATH')
socket := env_var_or_default('XDG_RUNTIME_DIR', '/tmp') + "/wayland-moon-0"
theme := "config/themes/moon-night.json"
exe := "_build/native/debug/build/compositor/bin/bin.exe"
release_exe := "_build/native/release/build/compositor/bin/bin.exe"
tcc := justfile_directory() + "/scripts/tcc/tcc"
default:
@just --list
# Build the vendored tinycc (third_party/tinycc) into _build/tcc, once. Optional: `just build` uses any tcc it can find.
tcc-build:
#!/usr/bin/env bash
set -euo pipefail
[ -x _build/tcc/bin/tcc ] && exit 0
root="$PWD"
rm -rf _build/tcc-src
mkdir -p _build
cp -r third_party/tinycc _build/tcc-src
cd _build/tcc-src
./configure --prefix="$root/_build/tcc" >/dev/null
make -j"$(nproc)" >/dev/null
make install >/dev/null
# Build the panel's wasm modules (application menu, task list, clock, ...) into build/components.
modules:
scripts/build-modules.sh
# Debug build of the native compositor, compiled and linked with tcc ($TCC, the vendored build if present, or tcc on PATH). Never builds tcc itself.
build:
@{{tcc}} --which >/dev/null
MOON_CC={{tcc}} MOON_STUB_CC={{tcc}} moon build --target native --warn-list -a compositor/bin
# Optimised build with the system C compiler (slower to build, faster to run).
build-release:
moon build --target native --release --warn-list -a compositor/bin
# Run the compositor, built as a wasm component, in a window on your current Wayland session (close the window or Ctrl-C to stop). Connect clients via `just client`. The panel is empty until panel modules run in the component; `just run-native` has them.
run: compositor-wasm host-wasm
rm -f {{socket}}
host-wasm/target/release/moon-plasma-host build/compositor.wasm --socket {{socket}} --theme {{theme}} --window
# Run the native compositor (tcc debug build, with the wasm panel modules) in a window on your current Wayland session.
run-native: build modules
rm -f {{socket}}
{{exe}} --window --socket {{socket}} --theme {{theme}}
# Rebuild the Desktop Pulse plasmoid (wasm component) into compositor/wasm/testdata.
build-pulse:
moon build --target wasm --release
wasm-tools component embed wit _build/wasm/release/build/components/pulse/gen/gen.wasm --world pulse-widget --encoding utf16 -o _build/pulse.embed.wasm
wasm-tools component new _build/pulse.embed.wasm -o compositor/wasm/testdata/pulse.component.wasm
wasm-tools component targets --world pulse-widget wit compositor/wasm/testdata/pulse.component.wasm
# Run the compositor in a window with the Desktop Pulse widget loaded (live system + window integration).
run-pulse: build
rm -f {{socket}}
{{exe}} --window --socket {{socket}} --theme {{theme}} --widget compositor/wasm/testdata/pulse.component.wasm
# One frame of the desktop with Desktop Pulse loaded, to _build/pulse.png.
view-pulse: build
{{exe}} --socket {{socket}}-snap --theme {{theme}} --widget compositor/wasm/testdata/pulse.component.wasm --gfx-out _build/pulse.png
# Run the compositor with no window (clients only; no output).
run-headless: build modules
rm -f {{socket}}
{{exe}} --socket {{socket}} --theme {{theme}}
# Run the wasm compositor on the real display (DRM/KMS + libinput, through the host). Run from a login VT (Ctrl+Alt+F3), not inside another session. Ctrl+Alt+Backspace quits, Ctrl+Alt+F<n> switches VT.
run-drm: compositor-wasm host-wasm modules
rm -f {{socket}}
host-wasm/target/release/moon-plasma-host build/compositor.wasm --drm --socket {{socket}} --theme {{theme}}
# The same on the native compositor (system-cc release build), for comparison.
run-drm-native: build-release modules
rm -f {{socket}}
{{release_exe}} --drm --socket {{socket}} --theme {{theme}}
# Install the Moon Plasma login session (display-manager entry): the wasm compositor + its host. Asks for root once.
install-session: compositor-wasm host-wasm modules
run0 python3 session/install.py
# Install the login session with the native compositor instead.
install-session-native: build-release modules
run0 python3 session/install.py --native
# Remove the login session again.
uninstall-session:
run0 python3 session/install.py --remove
# Start a Wayland client inside the running compositor (default: foot).
client *cmd="foot":
WAYLAND_DISPLAY={{socket}} {{cmd}}
# Compositor + wasm component + lib tests.
test: modules
XDG_CONFIG_HOME="$(mktemp -d)" MOON_PLASMA_TEST_CONFIG=1 moon test --target native --warn-list -a compositor/renderer compositor/wasm compositor/host
moon test --target wasm --warn-list -a lib/shell lib/panel lib/clock lib/launcher lib/wm lib/taskbar lib/layoutpick lib/modmgr
# Render one composed frame to _build/e2e_frame.png (via the e2e test).
frame: modules
moon test --target native --warn-list -a compositor/host
@echo "wrote _build/e2e_frame.png"
# Everything CI runs.
ci:
scripts/test.sh
# Render one frame of the desktop to _build/desktop.png and open it.
view: build modules
{{exe}} --socket {{socket}}-snap --theme {{theme}} --gfx-out _build/desktop.png
xdg-open _build/desktop.png
# Time the native build (cold / warm / one-file edit), tcc vs system cc, on a temp copy: `just bench 5` or `just bench 3 "tcc cc cc-release"`.
bench runs="3" configs="tcc cc":
scripts/bench-build.sh {{runs}} "{{configs}}"
# Delete build output (compiled compositor, wasm modules, rendered frames) but keep the built tinycc in _build/tcc.
clean:
#!/usr/bin/env bash
set -euo pipefail
rm -rf build
[ -d _build ] && find _build -mindepth 1 -maxdepth 1 ! -name tcc -exec rm -rf {} + || true
echo "cleaned build/ and _build/ (kept _build/tcc; \`just clean-all\` removes that too)"
# Delete all build output, including the built tinycc (the next build recompiles it).
clean-all:
rm -rf _build build
# Build the compositor as a wasm component (build/compositor.wasm): imports only moonplasma:host/sys.
compositor-wasm:
scripts/build-compositor-wasm.sh
# Build the native host that runs the compositor component (wasmtime; implements the sys imports).
host-wasm:
cd host-wasm && cargo build --release