.PHONY: clean build test test-unit test-doc build_test fmt clippy create_docs ayce default help docs wasm test-nightly clippy-nightly nightly miri mutants tree tree-duplicates deny audit unused-deps install-tools install-nextest install-mutants watch install-watch
default: ayce
help:
@echo "Available targets:"
@echo " make (default) - Run ayce"
@echo " make build - Build the project"
@echo " make clean - Clean build artifacts"
@echo " make test - Run all tests (nextest for unit, cargo test for doc)"
@echo " make test-unit - Run unit tests via cargo-nextest"
@echo " make test-doc - Run doc tests via cargo test --doc"
@echo " make build_test - Clean once, then build and test"
@echo " make fmt - Format code"
@echo " make clippy - Run clippy linter"
@echo " make wasm - Check wasm32 target"
@echo " make create_docs - Build documentation"
@echo " make docs - Build docs and open in browser"
@echo " make ayce - Run fmt, build_test, clippy, wasm, and docs"
@echo " make help - Display this help message"
@echo ""
@echo "Nightly:"
@echo " make test-nightly - Run all tests with nightly"
@echo " make clippy-nightly - Run clippy with nightly and deny warnings"
@echo " make nightly - Run nightly test and clippy checks"
@echo " make miri - Run tests under Miri"
@echo " make mutants - Run mutation tests via cargo-mutants"
@echo " make unused-deps - Find unused dependencies with cargo-udeps"
@echo ""
@echo "Dependencies and Security:"
@echo " make tree - Show dependency tree"
@echo " make tree-duplicates - Show duplicate dependencies"
@echo " make deny - Run full cargo-deny checks"
@echo " make audit - Run advisory-only security audit"
@echo ""
@echo "Tools and Workflow:"
@echo " make install-tools - Install cargo-deny, cargo-udeps, cargo-nextest, and cargo-mutants"
@echo " make install-nextest - Install cargo-nextest"
@echo " make install-mutants - Install cargo-mutants"
@echo " make watch - Run cargo-watch for check/test loop"
@echo " make install-watch - Install cargo-watch"
@echo ""
clean:
cargo clean
build:
cargo build
define check_nextest
@if ! cargo nextest --version >/dev/null 2>&1; then \
echo "cargo-nextest is not installed."; \
printf "Install it now? [y/N] "; \
read answer; \
if [ "$$answer" = "y" ] || [ "$$answer" = "Y" ]; then \
cargo install cargo-nextest --locked; \
else \
echo "Aborting: cargo-nextest is required for unit tests."; \
exit 1; \
fi; \
fi
endef
test-unit:
$(check_nextest)
cargo nextest run
test-doc:
cargo test --doc
test: test-unit test-doc
define check_mutants
@if ! cargo mutants --version >/dev/null 2>&1; then \
echo "cargo-mutants is not installed."; \
printf "Install it now? [y/N] "; \
read answer; \
if [ "$$answer" = "y" ] || [ "$$answer" = "Y" ]; then \
cargo install cargo-mutants; \
else \
echo "Aborting: cargo-mutants is required for mutation testing."; \
exit 1; \
fi; \
fi
endef
mutants:
$(check_mutants)
cargo mutants
build_test: clean build test
fmt:
cargo fmt
clippy:
cargo clippy -- -W clippy::pedantic
wasm:
cargo check --target wasm32-unknown-unknown
test-nightly:
cargo +nightly test --all-targets --all-features
clippy-nightly:
cargo +nightly clippy --lib --all-features -- -D warnings
nightly: test-nightly clippy-nightly
miri:
cargo miri test
tree:
@echo "Showing dependency tree..."
cargo tree
tree-duplicates:
@echo "Showing duplicate dependencies..."
cargo tree --duplicates
deny:
@echo "Running cargo-deny checks..."
cargo deny check
audit:
@echo "Running security audit..."
cargo deny check advisories
unused-deps:
@echo "Checking for unused dependencies..."
cargo +nightly udeps --all-features
create_docs:
cargo doc --no-deps
docs: create_docs
@DOC_PATH="./target/doc/wincounter/index.html"; \
if command -v xdg-open >/dev/null 2>&1; then \
xdg-open "$$DOC_PATH"; \
elif command -v open >/dev/null 2>&1; then \
open "$$DOC_PATH"; \
else \
echo "No supported opener found (tried xdg-open and open)."; \
echo "Open $$DOC_PATH manually."; \
exit 1; \
fi
ayce: fmt build_test clippy wasm create_docs
install-nextest:
cargo install cargo-nextest --locked
install-mutants:
cargo install cargo-mutants
install-tools:
@echo "Installing development tools..."
cargo install cargo-deny
cargo install cargo-udeps
cargo install cargo-nextest --locked
cargo install cargo-mutants
@echo ""
@echo "Tools installed!"
@echo ""
watch:
cargo watch -x "check" -x "test"
install-watch:
cargo install cargo-watch