.PHONY: help fetch build build-release run tui install fmt fmt-check lint clippy test test-verbose test-release test-watch test-minimal-path ci doctor doctor-release audit msrv changelog-rc-check clean
SHELL := /bin/bash
CARGO ?= cargo
GWM_ENV := GWM_NO_GLOBAL_CONFIG=1
TAG ?=
.DEFAULT_GOAL := help
GREEN = \033[0;32m
YELLOW = \033[0;33m
RED = \033[0;31m
BLUE = \033[0;34m
BOLD = \033[1m
NC = \033[0m
help:
@printf "${YELLOW}${BOLD}Available commands:${NC}\n"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "${GREEN}make %-20s${NC} %s\n", $$1, $$2}'
fetch:
@printf "${YELLOW}Fetching Cargo dependencies...${NC}\n"
$(CARGO) fetch
@printf "${GREEN}Dependencies fetched.${NC}\n"
install:
@printf "${YELLOW}Installing local gwm binary...${NC}\n"
$(CARGO) install --path . --force
@printf "${GREEN}Local gwm binary installed.${NC}\n"
run:
@printf "${YELLOW}Running gwm CLI help...${NC}\n"
$(GWM_ENV) $(CARGO) run -- --help
@printf "${GREEN}CLI help completed.${NC}\n"
tui:
@printf "${YELLOW}Opening gwm TUI...${NC}\n"
$(GWM_ENV) $(CARGO) run --
doctor:
@printf "${YELLOW}Running gwm doctor...${NC}\n"
$(GWM_ENV) $(CARGO) run -- doctor
@printf "${GREEN}gwm doctor completed.${NC}\n"
doctor-release:
@printf "${YELLOW}Building release binary for doctor...${NC}\n"
$(CARGO) build --release --quiet
@printf "${YELLOW}Running release gwm doctor...${NC}\n"
$(GWM_ENV) ./target/release/gwm doctor
@printf "${GREEN}Release gwm doctor completed.${NC}\n"
build:
@printf "${YELLOW}Building debug binary and library...${NC}\n"
$(CARGO) build
@printf "${GREEN}Build completed.${NC}\n"
build-release:
@printf "${YELLOW}Building release binary...${NC}\n"
$(CARGO) build --release
@printf "${GREEN}Release build completed.${NC}\n"
fmt:
@printf "${YELLOW}Formatting Rust sources...${NC}\n"
$(CARGO) fmt --all
@printf "${GREEN}Rust sources formatted.${NC}\n"
fmt-check:
@printf "${YELLOW}Checking Rust formatting...${NC}\n"
$(CARGO) fmt --all -- --check
@printf "${GREEN}Rust formatting is clean.${NC}\n"
lint: clippy
clippy:
@printf "${YELLOW}Running clippy...${NC}\n"
$(CARGO) clippy --all-targets --all-features -- -D warnings
@printf "${GREEN}Clippy completed.${NC}\n"
msrv:
@printf "${YELLOW}Checking MSRV compatibility...${NC}\n"
$(CARGO) clippy --all-targets --all-features -- -W clippy::incompatible_msrv
@printf "${GREEN}MSRV compatibility check completed.${NC}\n"
test:
@printf "${YELLOW}Running full test suite...${NC}\n"
$(GWM_ENV) $(CARGO) test
@printf "${GREEN}Tests completed.${NC}\n"
test-verbose:
@printf "${YELLOW}Running full test suite with verbose output...${NC}\n"
$(GWM_ENV) $(CARGO) test --verbose
@printf "${GREEN}Verbose tests completed.${NC}\n"
test-release:
@printf "${YELLOW}Running release-mode test suite...${NC}\n"
$(GWM_ENV) $(CARGO) test --release
@printf "${GREEN}Release-mode tests completed.${NC}\n"
test-watch:
@printf "${YELLOW}Watching tests with cargo-watch...${NC}\n"
$(GWM_ENV) $(CARGO) watch -x test
test-minimal-path:
@printf "${YELLOW}Running tests under stripped PATH...${NC}\n"
@cargo_path="$$(command -v $(CARGO))"; \
if [ -z "$$cargo_path" ]; then \
printf "${RED}cargo not found in PATH${NC}\n" >&2; \
exit 1; \
fi; \
PATH="$$(dirname "$$cargo_path"):/usr/bin:/bin" $(GWM_ENV) $(CARGO) test
@printf "${GREEN}Stripped-PATH tests completed.${NC}\n"
ci: fmt-check clippy build test
@printf "${GREEN}${BOLD}Local CI checks completed.${NC}\n"
audit:
@printf "${YELLOW}Running cargo audit...${NC}\n"
$(CARGO) audit
@printf "${GREEN}Cargo audit completed.${NC}\n"
changelog-rc-check: ## Check Unreleased changelog against previous RC (usage: make changelog-rc-check TAG=vX.Y.Z-rc.N)
@printf "${YELLOW}Checking RC changelog duplicates...${NC}\n"
@if [ -z "$(TAG)" ]; then \
printf "${RED}Error: TAG is required. Usage: make changelog-rc-check TAG=vX.Y.Z-rc.N${NC}\n" >&2; \
exit 2; \
fi
./.github/scripts/check-rc-changelog-dupes.sh "$(TAG)"
@printf "${GREEN}RC changelog check completed.${NC}\n"
clean:
@printf "${YELLOW}Cleaning Cargo build artifacts...${NC}\n"
$(CARGO) clean
@printf "${GREEN}Cargo artifacts cleaned.${NC}\n"