-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·62 lines (55 loc) · 2.89 KB
/
bootstrap.sh
File metadata and controls
executable file
·62 lines (55 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
TOOLS_ROOT=$(git -C "$SCRIPT_DIR" worktree list 2>/dev/null | head -1 | awk '{print $1}')
export MISE_DATA_DIR="${TOOLS_ROOT:-$SCRIPT_DIR}/tools"
export MISE_INSTALL_PATH="$MISE_DATA_DIR/mise"
export MISE_INSTALL_HELP=0
export MISE_GLOBAL_CONFIG_FILE=/dev/null
export ZIG_GLOBAL_CACHE_DIR="$MISE_DATA_DIR/zig-cache"
export PATH="$MISE_DATA_DIR:$PATH"
http() { curl --progress-bar "$@" || wget -qO- "$@"; }
# ─── macOS prerequisites ──────────────────────────────────────────────────
if [[ "$(uname -s)" == "Darwin" ]]; then
if ! command -v brew &>/dev/null; then
echo "ERROR: Homebrew is required on macOS. Install from https://brew.sh"
[[ "${BASH_SOURCE[0]}" == "${0}" ]] && exit 1 || return 1
fi
# Ensure git-lfs and cmake are available
_brew_missing=()
command -v git-lfs &>/dev/null || _brew_missing+=(git-lfs)
command -v cmake &>/dev/null || _brew_missing+=(cmake)
if (( ${#_brew_missing[@]} )); then
echo "Installing missing brew packages: ${_brew_missing[*]}"
brew install "${_brew_missing[@]}"
fi
# Check for full Xcode (needed for Metal shader compilation)
if ! xcrun metal --version &>/dev/null; then
echo ""
echo "=== Xcode Required ==="
echo "Full Xcode.app is needed for Metal shader compilation."
echo ""
echo "Option 1: App Store GUI or website (required for first-time install)"
echo " Open App Store → search 'Xcode' → Install"
echo " Or download from: https://developer.apple.com/xcode/"
echo ""
echo "Option 2: Command line (only works if Xcode was previously installed)"
echo " brew install mas && mas install 497799835"
echo ""
echo "After installing Xcode:"
echo " sudo xcodebuild -license accept"
echo " sudo xcode-select -s /Applications/Xcode.app/Contents/Developer"
echo " xcodebuild -downloadComponent MetalToolchain (NO sudo — per-user install)"
echo ""
# Don't abort — Xcode is only needed for rebuild-libs, not for building
# against pre-built dylibs
fi
fi
# ─── Common setup ─────────────────────────────────────────────────────────
[[ -f "$MISE_INSTALL_PATH" ]] || http https://mise.run | sh
git -C "$SCRIPT_DIR" submodule update --init --recursive --quiet
command -v git-lfs &>/dev/null && git lfs install --local && git -C "$SCRIPT_DIR" lfs pull
mise trust --quiet "$SCRIPT_DIR"
mise install
eval "$(mise env)"
# If this script is being executed (not sourced) and has an argument, run it with bun
[[ "${BASH_SOURCE[0]}" == "${0}" && -n "${1}" ]] && exec bun "$@"