2026-02-14 13:22:04 +01:00
|
|
|
# OS Detection
|
|
|
|
|
OS := $(shell uname -s)
|
2026-02-14 12:12:59 +01:00
|
|
|
ARCH := $(shell uname -m)
|
|
|
|
|
|
2026-02-14 13:22:04 +01:00
|
|
|
# Paths
|
2026-08-31 16:11:40 +02:00
|
|
|
CARGO_HOME ?= $(HOME)/.cargo
|
|
|
|
|
CARGO_BIN_DIR ?= $(CARGO_HOME)/bin
|
2026-02-14 13:22:04 +01:00
|
|
|
|
2026-02-14 12:12:59 +01:00
|
|
|
# Tool Commands
|
2026-08-31 16:11:40 +02:00
|
|
|
resolve_tool = $(or $(shell command -v $(1) 2>/dev/null),$(CARGO_BIN_DIR)/$(1))
|
|
|
|
|
RUSTUP ?= $(call resolve_tool,rustup)
|
|
|
|
|
CARGO ?= $(call resolve_tool,cargo)
|
|
|
|
|
CROSS ?= $(call resolve_tool,cross)
|
|
|
|
|
TRUNK ?= $(call resolve_tool,trunk)
|
|
|
|
|
WASM_BINDGEN ?= $(call resolve_tool,wasm-bindgen)
|
|
|
|
|
CARGO_SET_VERSION ?= $(call resolve_tool,cargo-set-version)
|
2026-09-04 10:49:45 +02:00
|
|
|
CARGO_MACHETE ?= $(call resolve_tool,cargo-machete)
|
2026-08-31 16:11:40 +02:00
|
|
|
MDBOOK ?= $(call resolve_tool,mdbook)
|
|
|
|
|
PINNED_NIGHTLY_TOOLCHAIN := nightly-2026-05-01
|
|
|
|
|
NIGHTLY_TOOLCHAIN ?= $(shell if $(RUSTUP) toolchain list 2>/dev/null | grep -q '^$(PINNED_NIGHTLY_TOOLCHAIN)'; then echo $(PINNED_NIGHTLY_TOOLCHAIN); else echo nightly; fi)
|
2026-02-14 13:22:04 +01:00
|
|
|
|
2026-02-14 12:12:59 +01:00
|
|
|
# Explicitly force stable/nightly to avoid system-wide overrides
|
|
|
|
|
CARGO_STABLE := $(CARGO) +stable
|
2026-06-04 18:00:37 +02:00
|
|
|
CARGO_NIGHTLY := $(CARGO) +$(NIGHTLY_TOOLCHAIN)
|
2026-02-14 12:12:59 +01:00
|
|
|
|
|
|
|
|
# Colors for terminal output
|
|
|
|
|
AQUA := \033[36m
|
|
|
|
|
RESET := \033[0m
|
|
|
|
|
BOLD := \033[1m
|
|
|
|
|
|
|
|
|
|
.DEFAULT_GOAL := help
|
|
|
|
|
|
2026-08-27 18:36:23 +05:00
|
|
|
# Number of CPUs (portable): try GNU `nproc`, then POSIX `getconf`, then macOS `sysctl`
|
|
|
|
|
CPU_COUNT := $(shell nproc 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1)
|
|
|
|
|
CARGO_BUILD_JOBS := $(CPU_COUNT)
|
|
|
|
|
|
2026-02-14 12:12:59 +01:00
|
|
|
.PHONY: help
|
|
|
|
|
help: ## Display this help
|
|
|
|
|
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make $(AQUA)<target>$(RESET)\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " $(AQUA)%-26s$(RESET) %s\n", $$1, $$2 } /^##@/ { printf "\n$(BOLD)%s$(RESET)\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
|
|
|
|
|
|
|
|
|
|
##@ Prerequisites:
|
|
|
|
|
|
|
|
|
|
.PHONY: install-tools
|
2026-09-04 10:49:45 +02:00
|
|
|
install-tools: rustup install-nightly-fmt cross trunk wasm-bindgen cargo-set-version cargo-machete mdbook markdownlint ## Install required development tools
|
2026-02-14 12:12:59 +01:00
|
|
|
|
|
|
|
|
.PHONY: install-nightly-fmt
|
|
|
|
|
install-nightly-fmt: ## Install nightly toolchain specifically for formatting
|
|
|
|
|
@echo "📦 Ensuring nightly rustfmt is available"
|
2026-06-04 18:00:37 +02:00
|
|
|
@$(RUSTUP) toolchain install $(NIGHTLY_TOOLCHAIN) --component rustfmt --profile minimal
|
2026-02-14 12:12:59 +01:00
|
|
|
@echo "✅ Nightly rustfmt ready"
|
|
|
|
|
|
2026-02-14 13:22:04 +01:00
|
|
|
.PHONY: rustup
|
|
|
|
|
rustup: $(RUSTUP) ## Install Rust toolchain and cargo
|
|
|
|
|
|
|
|
|
|
$(RUSTUP):
|
|
|
|
|
@echo "📦 Installing cargo"
|
|
|
|
|
@curl -sL https://sh.rustup.rs | sh -s -- -y
|
|
|
|
|
@echo "✅ Cargo installed"
|
|
|
|
|
|
|
|
|
|
.PHONY: cross
|
|
|
|
|
cross: $(CROSS) ## Install cross (multi-platform build tool)
|
|
|
|
|
|
|
|
|
|
$(CROSS):
|
|
|
|
|
@echo "📦 Installing cross"
|
|
|
|
|
@$(CARGO) install cross
|
|
|
|
|
@echo "✅ Cross installed"
|
|
|
|
|
|
|
|
|
|
.PHONY: trunk
|
|
|
|
|
trunk: $(TRUNK) ## Install trunk (frontend build tool)
|
|
|
|
|
|
|
|
|
|
$(TRUNK):
|
|
|
|
|
@echo "📦 Installing trunk"
|
|
|
|
|
@$(CARGO) install trunk
|
|
|
|
|
@echo "✅ Trunk installed"
|
|
|
|
|
|
|
|
|
|
.PHONY: wasm-bindgen
|
|
|
|
|
wasm-bindgen: $(WASM_BINDGEN) ## Install wasm-bindgen CLI (for frontend builds)
|
|
|
|
|
|
|
|
|
|
$(WASM_BINDGEN):
|
|
|
|
|
@echo "📦 Installing wasm-bindgen CLI"
|
|
|
|
|
@$(CARGO) install wasm-bindgen-cli
|
|
|
|
|
@echo "✅ wasm-bindgen CLI installed"
|
|
|
|
|
|
|
|
|
|
.PHONY: cargo-set-version
|
|
|
|
|
cargo-set-version: $(CARGO_SET_VERSION) ## Install cargo-set-version (for version management)
|
|
|
|
|
|
|
|
|
|
$(CARGO_SET_VERSION):
|
|
|
|
|
@echo "📦 Installing $@"
|
|
|
|
|
@$(CARGO) install cargo-edit
|
|
|
|
|
@echo "✅ $@ installed"
|
|
|
|
|
|
2026-03-15 10:15:08 +01:00
|
|
|
.PHONY: mdbook
|
|
|
|
|
mdbook: $(MDBOOK) ## Install mdBook (documentation generator)
|
|
|
|
|
|
|
|
|
|
$(MDBOOK):
|
|
|
|
|
@echo "📦 Installing mdBook"
|
|
|
|
|
@$(CARGO) install mdbook
|
|
|
|
|
@echo "✅ mdBook installed"
|
|
|
|
|
|
2026-09-04 10:49:45 +02:00
|
|
|
.PHONY: cargo-machete
|
|
|
|
|
cargo-machete: $(CARGO_MACHETE) ## Install cargo-machete (unused dependency detector)
|
|
|
|
|
|
|
|
|
|
$(CARGO_MACHETE):
|
|
|
|
|
@echo "📦 Installing $@"
|
|
|
|
|
@$(CARGO) install cargo-machete
|
|
|
|
|
@echo "✅ $@ installed"
|
|
|
|
|
|
2026-02-14 15:13:11 +01:00
|
|
|
.PHONY: markdownlint
|
|
|
|
|
markdownlint: ## Install markdownlint-cli2 (requires npm)
|
|
|
|
|
@echo "📦 Installing markdownlint-cli2"
|
|
|
|
|
@command -v npm >/dev/null 2>&1 || { \
|
|
|
|
|
echo "❌ npm not found. Please install Node.js and npm first."; \
|
|
|
|
|
exit 1; \
|
|
|
|
|
}
|
|
|
|
|
@npm install -g markdownlint-cli2
|
|
|
|
|
@echo "✅ markdownlint-cli2 installed"
|
|
|
|
|
|
2026-02-14 12:12:59 +01:00
|
|
|
##@ Development:
|
|
|
|
|
|
2026-08-31 16:11:40 +02:00
|
|
|
.PHONY: verify validate ci
|
|
|
|
|
verify: ## Run format, clippy, markdown lint, tests, and trunk build (stops on error)
|
|
|
|
|
@$(MAKE) fmt
|
|
|
|
|
@$(MAKE) lint
|
|
|
|
|
@$(MAKE) markdown-lint
|
|
|
|
|
@$(MAKE) test
|
|
|
|
|
@$(MAKE) trunk-build
|
2026-09-04 10:49:45 +02:00
|
|
|
@$(MAKE) cargo-machete-check
|
2026-08-31 16:11:40 +02:00
|
|
|
|
|
|
|
|
validate: verify ## Alias for verify
|
|
|
|
|
ci: verify ## Alias for verify
|
|
|
|
|
|
|
|
|
|
.PHONY: trunk-build
|
|
|
|
|
trunk-build: ## Build frontend with Trunk (WASM)
|
|
|
|
|
@echo "==> Building frontend (trunk)"
|
|
|
|
|
@cd frontend && NO_COLOR=true $(TRUNK) build
|
|
|
|
|
|
2026-09-04 10:49:45 +02:00
|
|
|
.PHONY: cargo-machete-check
|
|
|
|
|
cargo-machete-check: ## Detect unused dependencies across all crates (auto-installs cargo-machete if missing)
|
|
|
|
|
@echo "==> Detecting unused dependencies"
|
|
|
|
|
@command -v $(CARGO_MACHETE) >/dev/null 2>&1 || { \
|
|
|
|
|
echo "📦 cargo-machete not found, installing..."; \
|
|
|
|
|
$(CARGO) install cargo-machete; \
|
|
|
|
|
echo "✅ cargo-machete installed"; \
|
|
|
|
|
}
|
|
|
|
|
@$(CARGO_MACHETE)
|
|
|
|
|
|
2026-02-14 12:12:59 +01:00
|
|
|
.PHONY: test
|
2026-08-27 18:36:23 +05:00
|
|
|
test: ## Run all workspace tests (Stable) — use detected CPU count for parallelism
|
|
|
|
|
@echo "==> Running tests (stable) with $(CPU_COUNT) jobs/threads"
|
|
|
|
|
@TMPDIR="$${TMPDIR:-/tmp}" RUST_TEST_THREADS=$(CPU_COUNT) ./bin/test.sh -j$(CPU_COUNT) --workspace -- --test-threads=$(CPU_COUNT)
|
|
|
|
|
|
|
|
|
|
.PHONY: build
|
|
|
|
|
build: ## Build the entire workspace in parallel using detected CPU count
|
|
|
|
|
@echo "==> Building workspace with $(CARGO_BUILD_JOBS) jobs"
|
|
|
|
|
@TMPDIR="$${TMPDIR:-/tmp}" $(CARGO_STABLE) build -j$(CARGO_BUILD_JOBS) --workspace
|
|
|
|
|
|
|
|
|
|
.PHONY: architecture-check
|
|
|
|
|
architecture-check: ## Verify workspace dependency direction
|
|
|
|
|
@echo "==> Checking the architecture gate itself"
|
|
|
|
|
./bin/check-workspace-deps-test.sh
|
|
|
|
|
@echo "==> Checking workspace dependency direction"
|
|
|
|
|
./bin/check-workspace-deps.sh
|
2026-02-14 12:12:59 +01:00
|
|
|
|
|
|
|
|
.PHONY: lint
|
2026-08-27 18:36:23 +05:00
|
|
|
lint: ## Run clippy linter (Nightly)
|
|
|
|
|
@echo "==> Running clippy (nightly)"
|
|
|
|
|
$(CARGO_NIGHTLY) clippy --workspace -- -D warnings
|
2026-02-14 12:12:59 +01:00
|
|
|
|
|
|
|
|
.PHONY: lint-fix
|
2026-08-27 18:36:23 +05:00
|
|
|
lint-fix: ## Automatically fix clippy suggestions (Nightly)
|
2026-02-14 12:12:59 +01:00
|
|
|
@echo "==> Applying clippy auto-fixes"
|
2026-08-27 18:36:23 +05:00
|
|
|
$(CARGO_NIGHTLY) clippy --fix --workspace --allow-dirty --allow-staged -- -D clippy::uninlined_format_args
|
2026-02-14 12:12:59 +01:00
|
|
|
|
|
|
|
|
.PHONY: fmt
|
|
|
|
|
fmt: ## Format all code using nightly rules (Compact)
|
|
|
|
|
@echo "==> Formatting code (nightly)"
|
|
|
|
|
$(CARGO_NIGHTLY) fmt --all
|
|
|
|
|
|
|
|
|
|
.PHONY: fmt-check
|
|
|
|
|
fmt-check: ## Check if code follows formatting rules (Nightly)
|
|
|
|
|
@echo "==> Checking formatting (nightly)"
|
|
|
|
|
$(CARGO_NIGHTLY) fmt --all -- --check
|
2026-02-14 15:13:11 +01:00
|
|
|
|
2026-09-15 12:51:09 +02:00
|
|
|
.PHONY: markdown-lint mdlint
|
2026-02-14 15:13:11 +01:00
|
|
|
markdown-lint: ## Lint markdown files
|
|
|
|
|
@echo "==> Linting markdown files"
|
2026-04-11 23:27:43 +02:00
|
|
|
# @command -v markdownlint-cli2 >/dev/null 2>&1 || { \
|
|
|
|
|
# echo "❌ markdownlint-cli2 not found. Install with: npm install -g markdownlint-cli2"; \
|
|
|
|
|
# exit 1; \
|
|
|
|
|
# }
|
2026-09-15 12:51:09 +02:00
|
|
|
@npx markdownlint-cli2 "docs/src/**/*.md" "README.md" "CHANGELOG.md" "CONTRIBUTING.md" "docker/README.md"
|
2026-02-14 15:13:11 +01:00
|
|
|
@echo "✅ Markdown linting complete"
|
2026-03-15 10:15:08 +01:00
|
|
|
|
2026-09-15 12:51:09 +02:00
|
|
|
mdlint: markdown-lint ## Alias for markdown-lint
|
|
|
|
|
|
2026-03-15 10:15:08 +01:00
|
|
|
.PHONY: docs
|
|
|
|
|
docs: mdbook ## Build static documentation into frontend/build/docs
|
|
|
|
|
@echo "==> Building documentation"
|
|
|
|
|
@$(MDBOOK) build
|
|
|
|
|
@echo "✅ Documentation built at frontend/build/docs"
|
|
|
|
|
|
|
|
|
|
.PHONY: docs-serve
|
|
|
|
|
docs-serve: mdbook ## Serve documentation locally with mdBook
|
|
|
|
|
@echo "==> Serving documentation"
|
|
|
|
|
@$(MDBOOK) serve --open
|
|
|
|
|
|
|
|
|
|
.PHONY: docs-clean
|
|
|
|
|
docs-clean: ## Remove generated documentation output
|
|
|
|
|
@echo "==> Removing generated documentation"
|
|
|
|
|
@rm -rf frontend/build/docs
|
|
|
|
|
@echo "✅ Documentation output removed"
|
|
|
|
|
|
|
|
|
|
.PHONY: web-dist
|
|
|
|
|
web-dist: mdbook trunk ## Build static documentation and frontend assets
|
|
|
|
|
@echo "==> Building web assets"
|
|
|
|
|
@./bin/build_fe.sh release
|
|
|
|
|
@echo "✅ Web assets built"
|