WEFT_OS/docs/building.md

98 lines
3 KiB
Markdown
Raw Permalink Normal View History

# 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 stubs compile and print READY without running an actual WebView. 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
```
build: select compiling Servo and Stylo fork revisions Both Servo hosts tracked the marcoallegretti/servo `servo-weft` branch, which the lockfile resolved to 8e7dc40. That revision's servo-layout does not compile (E0308 and E0716 in build_backdrop_filter). WEFT also resolved upstream Stylo dca3934, where backdrop-filter is gated behind layout.unimplemented, because the Servo fork's own [patch] for Stylo does not apply to dependents. Pin Servo by revision to f0bb1aa (8e7dc40 plus the build fix) and add a root [patch."https://github.com/servo/stylo"] selecting the marcoallegretti/stylo fork at f1ba496 for all eight Stylo crates Servo uses. Cargo.lock changes only the 66 source lines of those packages. Record both pins, their reachable branches, purpose and removal conditions in SERVO_PIN.md, and restate its limitations against executed evidence. Update the Nix outputHashes: the Stylo hash is recomputed for f1ba496 with the method that reproduces the previous dca3934 value; the Servo hash is not yet known for f0bb1aa and is left as lib.fakeHash, so Nix builds report the expected value instead of using a stale one. Validation: - cargo metadata --locked: ok; no servo/stylo sources remain in the lock - cargo check -p weft-servo-shell --features servo-embed --locked: all of Servo, including servo-layout, compiles; the remaining errors are in the shell's own embedder code - cargo fmt --check; portable workspace tests: 78 passed - Nix fetchgit could not run here (archive downloads and the sandbox's TLS to the proxy fail), so the Servo hash remains unverified
2026-10-09 00:13:08 +00:00
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`.
## 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
```
build: select compiling Servo and Stylo fork revisions Both Servo hosts tracked the marcoallegretti/servo `servo-weft` branch, which the lockfile resolved to 8e7dc40. That revision's servo-layout does not compile (E0308 and E0716 in build_backdrop_filter). WEFT also resolved upstream Stylo dca3934, where backdrop-filter is gated behind layout.unimplemented, because the Servo fork's own [patch] for Stylo does not apply to dependents. Pin Servo by revision to f0bb1aa (8e7dc40 plus the build fix) and add a root [patch."https://github.com/servo/stylo"] selecting the marcoallegretti/stylo fork at f1ba496 for all eight Stylo crates Servo uses. Cargo.lock changes only the 66 source lines of those packages. Record both pins, their reachable branches, purpose and removal conditions in SERVO_PIN.md, and restate its limitations against executed evidence. Update the Nix outputHashes: the Stylo hash is recomputed for f1ba496 with the method that reproduces the previous dca3934 value; the Servo hash is not yet known for f0bb1aa and is left as lib.fakeHash, so Nix builds report the expected value instead of using a stale one. Validation: - cargo metadata --locked: ok; no servo/stylo sources remain in the lock - cargo check -p weft-servo-shell --features servo-embed --locked: all of Servo, including servo-layout, compiles; the remaining errors are in the shell's own embedder code - cargo fmt --check; portable workspace tests: 78 passed - Nix fetchgit could not run here (archive downloads and the sandbox's TLS to the proxy fail), so the Servo hash remains unverified
2026-10-09 00:13:08 +00:00
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