From fb733209e0cf743b079f5bd01688ba4c9b294c86 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Wed, 11 Feb 2026 16:53:02 +0100 Subject: [PATCH] chore(config): add automated Rust install to make setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds tooling/install-rust script that installs Rust via rustup if not present, with clippy and rustfmt components. Idempotent — skips when already installed. Co-Authored-By: Claude Opus 4.6 --- Makefile | 4 +--- docs/DEVOPS.md | 2 +- tooling/install-rust | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100755 tooling/install-rust diff --git a/Makefile b/Makefile index 85bbb2bbe..dc8060af3 100644 --- a/Makefile +++ b/Makefile @@ -33,9 +33,7 @@ setup: setup-rust setup-godot setup-tooling decisions-sync @echo "Dev environment ready." setup-rust: - @echo "Checking Rust toolchain..." - @command -v cargo >/dev/null 2>&1 || { echo "Install Rust: https://rustup.rs"; exit 1; } - @rustup component add clippy rustfmt + @tooling/install-rust setup-godot: @GODOT_VERSION=$(GODOT_VERSION) tooling/install-godot diff --git a/docs/DEVOPS.md b/docs/DEVOPS.md index de4c35f9b..7bfdbaf77 100644 --- a/docs/DEVOPS.md +++ b/docs/DEVOPS.md @@ -22,7 +22,7 @@ Unit tests live inside their respective projects (`server/` uses `#[cfg(test)]` | Tool | Version | Purpose | |------|---------|---------| -| Rust (via rustup) | stable | Server compilation, clippy, rustfmt | +| Rust (via rustup) | stable | Server compilation, clippy, rustfmt (auto-installed by `make setup`) | | Godot | 4.x | Client editor and runtime (auto-installed to `~/bin/` by `make setup`) | | Python | 3.x | Tooling scripts, db connectors | | Make | any | Task runner (see below) | diff --git a/tooling/install-rust b/tooling/install-rust new file mode 100755 index 000000000..d8dd7ff98 --- /dev/null +++ b/tooling/install-rust @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# tooling/install-rust — Install Rust via rustup and add required components +# +# Usage: +# ./tooling/install-rust +# +# Installs rustup + stable toolchain if not present, then ensures +# clippy and rustfmt components are installed. Idempotent. + +set -euo pipefail + +if command -v rustup >/dev/null 2>&1; then + echo "Rust already installed: $(rustc --version)" + rustup component add clippy rustfmt 2>/dev/null + echo "Components verified: clippy, rustfmt" + exit 0 +fi + +echo "Installing Rust via rustup..." + +if ! command -v curl >/dev/null 2>&1; then + echo "Error: curl is required to install Rust." + exit 1 +fi + +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --component clippy rustfmt + +# Source cargo env for the rest of this script +# shellcheck source=/dev/null +. "$HOME/.cargo/env" + +echo "Rust installed: $(rustc --version)" +echo "Components: clippy, rustfmt"