feat: add toolchain check scripts and mise tasks

- scripts/check-toolchain.sh: checks gcc, homebrew, mise, go, node
- scripts/check-docker-toolchain.sh: checks docker, compose, colima (macOS), buildx
- mise tasks: check-toolchain, check-docker-toolchain, check-all
This commit is contained in:
2026-06-21 21:46:11 -07:00
parent 48d6d8c4d3
commit e671320bbb
3 changed files with 232 additions and 0 deletions
+114
View File
@@ -0,0 +1,114 @@
#!/usr/bin/env bash
# Check core toolchain: gcc, homebrew, mise, go, node.
# Usage: ./scripts/check-toolchain.sh
set -euo pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
ok() { echo -e " ${GREEN}${NC} $1"; }
warn() { echo -e " ${YELLOW}!${NC} $1"; }
fail() { echo -e " ${RED}${NC} $1"; }
echo "=== Core Toolchain Check ==="
echo ""
# ─── GCC / C Compiler ──────────────────────────────────────────────────
echo "C Compiler:"
if command -v gcc &>/dev/null; then
gcc_ver=$(gcc --version 2>/dev/null | head -1)
ok "gcc found: $gcc_ver"
elif command -v cc &>/dev/null; then
cc_ver=$(cc --version 2>/dev/null | head -1)
ok "cc found: $cc_ver"
elif command -v clang &>/dev/null; then
clang_ver=$(clang --version 2>/dev/null | head -1)
ok "clang found: $clang_ver"
else
fail "No C compiler found"
echo " Install: brew install gcc (macOS) or sudo apt install build-essential (Linux)"
exit 1
fi
# Verify gcc can compile (catches broken Xcode toolchain on macOS)
tmp_src=$(mktemp /tmp/toolchain_test.XXXXXX.c)
tmp_bin=$(mktemp /tmp/toolchain_test.XXXXXX)
trap 'rm -f "$tmp_src" "$tmp_bin"' EXIT
cat > "$tmp_src" << 'EOF'
int main(void) { return 0; }
EOF
if cc "$tmp_src" -o "$tmp_bin" 2>/dev/null || gcc "$tmp_src" -o "$tmp_bin" 2>/dev/null; then
ok "gcc can compile test program"
rm -f "$tmp_bin"
else
fail "gcc cannot compile — toolchain may be broken"
echo " Fix: xcode-select --install (macOS) or reinstall gcc"
exit 1
fi
echo ""
# ─── Homebrew ──────────────────────────────────────────────────────────
echo "Homebrew:"
if command -v brew &>/dev/null; then
brew_path=$(which brew)
ok "brew found at $brew_path"
else
warn "brew not found"
if [[ "$(uname)" == "Darwin" ]]; then
echo " Install: /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
fi
fi
echo ""
# ─── Mise ──────────────────────────────────────────────────────────────
echo "Mise:"
if command -v mise &>/dev/null; then
mise_ver=$(mise --version 2>/dev/null)
ok "mise found: $mise_ver"
else
warn "mise not found"
if command -v brew &>/dev/null; then
echo " Install: brew install mise"
else
echo " Install: curl https://mise.run | sh"
fi
fi
echo ""
# ─── Go ────────────────────────────────────────────────────────────────
echo "Go:"
if command -v go &>/dev/null; then
go_ver=$(go version 2>/dev/null)
ok "go found: $go_ver"
else
fail "go not found"
if command -v mise &>/dev/null; then
echo " Install: mise install go"
else
echo " Install: brew install go (macOS) or use mise"
fi
exit 1
fi
echo ""
# ─── Node ──────────────────────────────────────────────────────────────
echo "Node:"
if command -v node &>/dev/null; then
node_ver=$(node --version 2>/dev/null)
ok "node found: $node_ver"
else
warn "node not found (required only for Electron)"
if command -v mise &>/dev/null; then
echo " Install: mise install node"
fi
fi
echo ""
echo "=== Core toolchain check complete ==="