mirror of
https://github.com/marcoallegretti/WEFT_OS.git
synced 2026-11-22 08:13:59 +00:00
Nothing checked that input reaches a page through the compositor; the Servo hosts' input forwarding had only been compiled. tests/frame/check_input.py runs weft-servo-shell with tests/frame/input.html on the nested desktop and injects real X input with xdotool into weft-compositor's window. The compositor's winit backend routes it through its seat to the Wayland client, which has no X display. The page must react in its presented pixels: clicks 6 px either side of the boundary between its halves change only the half under the pointer, and the a and Shift+a key presses arrive with the right key value and modifier. The harness gives the compositor's X window input focus, as a window manager would; the client's keyboard focus comes from the compositor's click-to-focus. The nested desktop setup shared with check_frame.py moves to tests/frame/session.py. Xvfb now reports the display it picked through -displayfd, so concurrent runs cannot share an X server, and a run clears only the logs and capture it writes. Validation: - check_input.py: 3 of 3 runs pass; two concurrent runs pass - negative pages fail: no script; left click handled by the right half; an element extending the left half 20 px across the boundary; a key handler ignoring Shift - check_frame.py --host system, --host app, --host app --slow-style 3 pass after the refactor - unverified: key release and repeat, pointer motion and button release events, wheel, focus loss, non-US layouts, non-ASCII text, scale changes, weft-app-shell input
129 lines
4.3 KiB
Markdown
129 lines
4.3 KiB
Markdown
# Building WEFT OS
|
||
|
||
## Prerequisites
|
||
|
||
Linux (x86_64 or aarch64). Building on Windows is supported for workspace validation only; runtime components require Linux kernel interfaces.
|
||
|
||
System packages (openSUSE):
|
||
|
||
```sh
|
||
sudo zypper install -y \
|
||
libwayland-devel libxkbcommon-devel \
|
||
libglvnd-devel libgbm-devel libdrm-devel \
|
||
libinput-devel seatd-devel libudev-devel systemd-devel \
|
||
pkg-config clang cmake python3
|
||
```
|
||
|
||
Rust toolchain: pinned in `rust-toolchain.toml`. Run `rustup show` to confirm the active toolchain matches.
|
||
|
||
## Workspace crates (non-Servo)
|
||
|
||
```sh
|
||
cargo build --workspace \
|
||
--exclude weft-servo-shell \
|
||
--exclude weft-app-shell
|
||
```
|
||
|
||
These crates do not require Servo and build in under two minutes.
|
||
|
||
## weft-compositor, weft-servo-shell, weft-app-shell (Linux)
|
||
|
||
```sh
|
||
cargo build -p weft-compositor
|
||
cargo build -p weft-servo-shell
|
||
cargo build -p weft-app-shell
|
||
```
|
||
|
||
Without `--features servo-embed`, the servo-shell and app-shell binaries compile for type and lint checks but exit with an error at startup; they never report readiness. This is the default and the CI baseline.
|
||
|
||
## Servo embedding (optional, slow)
|
||
|
||
```sh
|
||
cargo build -p weft-servo-shell --features servo-embed
|
||
cargo build -p weft-app-shell --features servo-embed
|
||
```
|
||
|
||
This fetches and compiles the Servo and Stylo forks at the revisions recorded in `Cargo.lock` (see `crates/weft-servo-shell/SERVO_PIN.md`). Expect 30–60 minutes on a clean build. Servo's dependencies include SpiderMonkey (C++), which requires `clang` and `python3`.
|
||
|
||
## Frame check
|
||
|
||
`tests/frame/check_frame.py` runs `weft-compositor` nested on Xvfb with the
|
||
winit backend, starts a Servo host showing `tests/frame/reference.html`, and
|
||
checks the presented pixels. It needs `Xvfb`, `xwd`, ImageMagick's `convert`
|
||
and a Mesa OpenGL driver (llvmpipe is sufficient).
|
||
|
||
```sh
|
||
cargo build -p weft-compositor
|
||
cargo build -p weft-servo-shell -p weft-app-shell \
|
||
--features weft-servo-shell/servo-embed,weft-app-shell/servo-embed
|
||
python3 tests/frame/check_frame.py --host system
|
||
python3 tests/frame/check_frame.py --host app
|
||
python3 tests/frame/check_frame.py --host app --slow-style 3
|
||
```
|
||
|
||
`--host app` also requires the page on screen within two seconds of
|
||
`weft-app-shell` printing `READY`; `--slow-style` delays a stylesheet that
|
||
reveals the page so premature readiness becomes visible.
|
||
|
||
Logs and the last capture are written to `target/frame-check`.
|
||
|
||
`tests/frame/check_input.py` uses the same nested desktop to send real X
|
||
pointer and keyboard input (with `xdotool`) through `weft-compositor` to
|
||
`weft-servo-shell` showing `tests/frame/input.html`, and checks that the
|
||
page reacts to clicks on either side of a boundary and to the `a` and
|
||
`Shift+a` keys. Logs and the last capture are written to `target/input-check`.
|
||
|
||
```sh
|
||
python3 tests/frame/check_input.py
|
||
```
|
||
|
||
## Demo apps (wasm32-wasip2)
|
||
|
||
Each demo is a standalone crate in `examples/`. Pre-built `app.wasm` binaries are committed. To rebuild:
|
||
|
||
```sh
|
||
rustup target add wasm32-wasip2
|
||
cd examples/org.weft.demo.counter
|
||
cargo build --release
|
||
# output: target/wasm32-wasip2/release/app.wasm
|
||
```
|
||
|
||
## weft-runtime with Wasmtime
|
||
|
||
```sh
|
||
cargo build -p weft-runtime --features wasmtime-runtime,net-fetch
|
||
```
|
||
|
||
Without `--features wasmtime-runtime`, the runtime prints READY and exits (stub mode, used in CI on platforms without Linux system dependencies).
|
||
|
||
## Signing packages
|
||
|
||
```sh
|
||
weft-pack generate-key ./keys
|
||
weft-pack sign ./examples/org.weft.demo.counter --key ./keys/weft-sign.key
|
||
weft-pack verify ./examples/org.weft.demo.counter --key ./keys/weft-sign.pub
|
||
```
|
||
|
||
## NixOS VM (requires Nix with flakes)
|
||
|
||
Build the VM image:
|
||
|
||
```sh
|
||
bash infra/vm/build.sh
|
||
```
|
||
|
||
Run with QEMU:
|
||
|
||
```sh
|
||
bash infra/vm/run.sh
|
||
```
|
||
|
||
See `infra/nixos/weft-packages.nix` for the package derivations. Its `outputHashes` hold one hash per git source in `Cargo.lock` (the Servo and Stylo forks); every package vendors them, so they must match the pinned revisions for any Nix package to build. The Nix shell packages do not yet enable `servo-embed`.
|
||
|
||
## CI
|
||
|
||
Three jobs run on every push to `main` and on pull requests:
|
||
|
||
- `cross-platform` — fmt, clippy, tests on Ubuntu and Windows (excludes Wayland crates)
|
||
- `linux-only` — clippy and tests for `weft-compositor`, `weft-servo-shell`, `weft-app-shell`
|
||
- `servo-embed-linux` — `cargo check --features servo-embed` for servo-shell and app-shell
|