#!/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" <