NAME=$(shell awk -F' *= *' '/^name/ {gsub(/"/, "", $$2); print $$2; exit}' Cargo.toml)
VERSION=$(shell awk -F' *= *' '/^version/ {gsub(/"/, "", $$2); print $$2; exit}' Cargo.toml)
.PHONY: all build test check audit outdated clean help tools update init-git
.PHONY: check-precommit test-release
all: check audit build test
build:
cargo build
release:
cargo build --release
test-quiet:
cargo nextest run --status-level fail
test:
cargo nextest run
test-release:
cargo nextest run --release
check-precommit:
@diff -uN .git/hooks/pre-commit .git-pre-commit-template || ( \
echo "+-------------------------------------------------------+"; \
echo "| ERROR: pre-commit outdated, 'make init-git' to update |"; \
echo "+-------------------------------------------------------+"; \
exit 1)
@echo "pre-commit: ✅ Up to date: .git/hooks/pre-commit (.git-pre-commit-template)"
precommit: check-precommit
.git/hooks/pre-commit
verify-msrv:
cargo msrv verify
check: check-precommit verify-msrv
cargo clippy --all-targets --all-features
cargo fmt --all --check
fix:
cargo fmt --all
cargo clippy --fix --lib -p $(NAME)
audit:
cargo audit
coverage:
cargo tarpaulin
outdated:
cargo outdated
update:
cargo update
clean:
cargo clean
tools:
rustup update
cargo install --locked cargo-outdated
cargo install --locked cargo-audit
cargo install --locked cargo-nextest
cargo install --locked cargo-tarpaulin
cargo install --locked cargo-msrv
init-git:
install -m 755 .git-pre-commit-template .git/hooks/pre-commit
help:
@echo; echo " Welcome to $(NAME)-v$(VERSION), available targets:"; echo
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf " %-14s %s\n", $$1, $$2}'
@echo