fix(dev): resolve the macOS Metal toolchain before building the shell

This commit is contained in:
2026-07-10 15:55:39 -04:00
parent e19dd6f808
commit 02ddd67078
+31
View File
@@ -1,6 +1,36 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
# gpui compiles its Metal shaders with `xcrun metal`, which ships only in the
# full Xcode Metal Toolchain — the standalone Command Line Tools do not provide
# it. Respect a developer directory that already resolves `metal`; otherwise
# fall back to a standard Xcode install; otherwise stop with the exact fix.
ely_ensure_metal_toolchain() {
if xcrun --find metal >/dev/null 2>&1; then
return 0
fi
local xcode_developer_dir="/Applications/Xcode.app/Contents/Developer"
if [[ -d "${xcode_developer_dir}" ]] &&
DEVELOPER_DIR="${xcode_developer_dir}" xcrun --find metal >/dev/null 2>&1; then
export DEVELOPER_DIR="${xcode_developer_dir}"
return 0
fi
cat >&2 <<'EOF'
error: the Metal shader compiler (`xcrun metal`) is unavailable.
gpui compiles Metal shaders at build time, which needs the full Xcode Metal
Toolchain. The Command Line Tools alone cannot build the macOS shell.
Fix (no sudo required):
1. Install Xcode from the App Store.
2. DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer \
xcodebuild -downloadComponent MetalToolchain
3. Re-run scripts/run_dev.sh
(or point DEVELOPER_DIR at a non-standard Xcode location).
EOF
return 1
}
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "${repo_root}" cd "${repo_root}"
target_dir="${CARGO_TARGET_DIR:-${repo_root}/target}" target_dir="${CARGO_TARGET_DIR:-${repo_root}/target}"
@@ -15,6 +45,7 @@ binary_suffix=""
if [[ "$(uname -s)" == "Darwin" ]]; then if [[ "$(uname -s)" == "Darwin" ]]; then
sidecar_features="servo-engine,hardware-render" sidecar_features="servo-engine,hardware-render"
rendering_context="hardware" rendering_context="hardware"
ely_ensure_metal_toolchain
fi fi
case "$(uname -s)" in case "$(uname -s)" in
MINGW*|MSYS*|CYGWIN*) binary_suffix=".exe" ;; MINGW*|MSYS*|CYGWIN*) binary_suffix=".exe" ;;