mirror of
https://github.com/marcoallegretti/WEFT_OS.git
synced 2026-11-22 08:13:59 +00:00
79 lines
3.1 KiB
Bash
79 lines
3.1 KiB
Bash
|
|
#!/bin/bash
|
||
|
|
# Development environment setup for remote cloud sessions.
|
||
|
|
# Installs system packages and Rust toolchains for WEFT_OS, and, when the
|
||
|
|
# servo and stylo forks are cloned next to this repo, wires them together
|
||
|
|
# with local cargo [patch] overrides.
|
||
|
|
set -euo pipefail
|
||
|
|
|
||
|
|
if [ "${CLAUDE_CODE_REMOTE:-}" != "true" ]; then
|
||
|
|
exit 0
|
||
|
|
fi
|
||
|
|
|
||
|
|
WEFT_DIR="${CLAUDE_PROJECT_DIR:-$(cd "$(dirname "$0")/../.." && pwd)}"
|
||
|
|
PARENT_DIR="$(dirname "$WEFT_DIR")"
|
||
|
|
SERVO_DIR="$PARENT_DIR/servo"
|
||
|
|
STYLO_DIR="$PARENT_DIR/stylo"
|
||
|
|
|
||
|
|
# System packages: WEFT CI set plus what Servo needs to build.
|
||
|
|
APT_PKGS=(
|
||
|
|
libwayland-dev libxkbcommon-dev libegl-dev libgles2-mesa-dev libgbm-dev
|
||
|
|
libdrm-dev libinput-dev libseat-dev libudev-dev libsystemd-dev
|
||
|
|
libdisplay-info-dev libfontconfig-dev libfreetype-dev libharfbuzz-dev
|
||
|
|
libx11-dev libxcursor-dev libxrandr-dev libxi-dev libssl-dev libdbus-1-dev
|
||
|
|
llvm-dev libclang-dev lld clang cmake ninja-build pkg-config m4 python3
|
||
|
|
libunwind-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
|
||
|
|
libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base
|
||
|
|
)
|
||
|
|
missing=()
|
||
|
|
for p in "${APT_PKGS[@]}"; do
|
||
|
|
dpkg -s "$p" >/dev/null 2>&1 || missing+=("$p")
|
||
|
|
done
|
||
|
|
if [ ${#missing[@]} -gt 0 ]; then
|
||
|
|
export DEBIAN_FRONTEND=noninteractive
|
||
|
|
apt-get update -q
|
||
|
|
apt-get install -y --no-install-recommends "${missing[@]}"
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Rust toolchains pinned by each repo's rust-toolchain.toml.
|
||
|
|
rustup toolchain install 1.93.0 --profile minimal -c clippy,rustfmt
|
||
|
|
if [ -d "$SERVO_DIR" ]; then
|
||
|
|
rustup toolchain install "$(sed -n 's/^channel = "\(.*\)"/\1/p' "$SERVO_DIR/rust-toolchain.toml")" \
|
||
|
|
--profile minimal -c clippy,rustfmt,llvm-tools,rustc-dev,rust-src
|
||
|
|
fi
|
||
|
|
|
||
|
|
# WEFT pins servo's `servo-weft` branch, which in turn uses stylo's
|
||
|
|
# `servo-weft` branch; make sure both are available locally.
|
||
|
|
for repo in "$SERVO_DIR" "$STYLO_DIR"; do
|
||
|
|
if [ -d "$repo/.git" ]; then
|
||
|
|
git -C "$repo" rev-parse --verify -q origin/servo-weft >/dev/null ||
|
||
|
|
git -C "$repo" fetch --depth=50 origin servo-weft:refs/remotes/origin/servo-weft || true
|
||
|
|
fi
|
||
|
|
done
|
||
|
|
|
||
|
|
# Point WEFT at the local servo fork and WEFT + servo at the local stylo fork.
|
||
|
|
# These patches rewrite Cargo.lock `source` lines; don't commit those hunks.
|
||
|
|
# Check out the `servo-weft` work in both forks before building servo-embed.
|
||
|
|
if [ -d "$SERVO_DIR" ] && [ -d "$STYLO_DIR" ]; then
|
||
|
|
mkdir -p "$PARENT_DIR/.cargo"
|
||
|
|
cat > "$PARENT_DIR/.cargo/config.toml" <<CFG
|
||
|
|
# Generated by WEFT_OS/.claude/hooks/session-start.sh. Delete to build
|
||
|
|
# against the git pins. Don't commit the Cargo.lock changes this causes.
|
||
|
|
[patch."https://github.com/marcoallegretti/servo"]
|
||
|
|
servo = { path = "$SERVO_DIR/components/servo" }
|
||
|
|
|
||
|
|
[patch."https://github.com/servo/stylo"]
|
||
|
|
selectors = { path = "$STYLO_DIR/selectors" }
|
||
|
|
servo_arc = { path = "$STYLO_DIR/servo_arc" }
|
||
|
|
stylo = { path = "$STYLO_DIR/style" }
|
||
|
|
stylo_atoms = { path = "$STYLO_DIR/stylo_atoms" }
|
||
|
|
stylo_dom = { path = "$STYLO_DIR/stylo_dom" }
|
||
|
|
stylo_malloc_size_of = { path = "$STYLO_DIR/malloc_size_of" }
|
||
|
|
stylo_static_prefs = { path = "$STYLO_DIR/stylo_static_prefs" }
|
||
|
|
stylo_traits = { path = "$STYLO_DIR/style_traits" }
|
||
|
|
CFG
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Prefetch WEFT dependencies so builds and tests work offline-ish.
|
||
|
|
cd "$WEFT_DIR"
|
||
|
|
cargo fetch
|