#!/usr/bin/env bash # # devel-setup.sh — one-time developer environment setup for mtgc. # # Installs the Tauri v2 Linux system libraries and the Tauri CLI, and verifies # the toolchain (Rust, Node, pkg-config libs) needed to build the desktop shell. # # Safe to re-run: package installs are idempotent and the CLI install is skipped # if already present. # # Usage: # ./scripts/devel-setup.sh # set -euo pipefail info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; } warn() { printf '\033[1;33m[warn]\033[0m %s\n' "$*"; } err() { printf '\033[1;31m[err]\033[0m %s\n' "$*" >&2; } # --- 1. Prerequisites already expected on the machine ---------------------- if ! command -v rustc >/dev/null 2>&1; then err "Rust not found. Install from https://rustup.rs and re-run." exit 1 fi info "Rust: $(rustc --version)" if ! command -v node >/dev/null 2>&1; then warn "Node.js not found — needed for the Vite/React frontend." warn "Install Node 18+ (e.g. 'sudo dnf install nodejs') before running the app." else info "Node: $(node --version)" fi # --- 2. Tauri v2 system libraries (Fedora / dnf) --------------------------- # # These are GTK3 packages by necessity, not choice: Tauri v2's Linux backend # (wry/tao) hard-depends on GTK3 + webkit2gtk-4.1. GTK4 support is tracked # upstream but unmerged with no ETA — see the README's "Why GTK3, not GTK4?" # note (tauri#7335, tao#1104, wry#1228) before "fixing" this in isolation. FEDORA_PKGS=( webkit2gtk4.1-devel gtk3-devel libappindicator-gtk3-devel librsvg2-devel file openssl-devel ) if command -v dnf >/dev/null 2>&1; then info "Installing Tauri system libraries via dnf (sudo required)…" sudo dnf install -y "${FEDORA_PKGS[@]}" else warn "dnf not found — this script targets Fedora." warn "Install the equivalents of: ${FEDORA_PKGS[*]}" warn "See https://tauri.app/start/prerequisites/ for your distro." fi # --- 3. Verify the libraries pkg-config will look for ---------------------- check_pkg() { if pkg-config --exists "$1" 2>/dev/null; then info "found $1" else warn "missing $1 (Tauri build may fail)" fi } if command -v pkg-config >/dev/null 2>&1; then check_pkg webkit2gtk-4.1 check_pkg gtk+-3.0 else warn "pkg-config not found; cannot verify libraries." fi # --- 4. Tauri v2 CLI ------------------------------------------------------- if cargo tauri --version >/dev/null 2>&1; then info "Tauri CLI: $(cargo tauri --version 2>&1 | head -1)" else info "Installing Tauri v2 CLI (cargo install tauri-cli --version '^2')…" cargo install tauri-cli --version '^2' fi info "Setup complete. Next: scaffold + run the desktop shell with 'cargo tauri dev'."