.PHONY: all build test bench coverage lint fmt examples paper-bench help clean
all: fmt lint test
build:
cargo build --release
test:
cargo test --all-features
test-verbose:
cargo test --all-features -- --nocapture
lint:
cargo clippy --all-features -- -D warnings
fmt:
cargo fmt --all
fmt-check:
cargo fmt --all -- --check
coverage:
@echo "๐ Running coverage analysis..."
@which cargo-llvm-cov > /dev/null 2>&1 || (echo "๐ฆ Installing cargo-llvm-cov..." && cargo install cargo-llvm-cov --locked)
@echo "๐งน Cleaning old coverage data..."
@cargo llvm-cov clean --workspace
@mkdir -p target/coverage
@echo "โ๏ธ Temporarily disabling global cargo config (mold breaks coverage)..."
@test -f ~/.cargo/config.toml && mv ~/.cargo/config.toml ~/.cargo/config.toml.cov-backup || true
@echo "๐งช Phase 1: Running tests with instrumentation..."
@cargo llvm-cov --no-report --all-features
@echo "๐ Phase 2: Generating coverage reports..."
@cargo llvm-cov report --html --output-dir target/coverage/html
@cargo llvm-cov report --lcov --output-path target/coverage/lcov.info
@echo "โ๏ธ Restoring global cargo config..."
@test -f ~/.cargo/config.toml.cov-backup && mv ~/.cargo/config.toml.cov-backup ~/.cargo/config.toml || true
@echo ""
@echo "๐ Coverage Summary:"
@cargo llvm-cov report --summary-only
@echo ""
@echo "๐ก HTML report: target/coverage/html/index.html"
coverage-summary:
@cargo llvm-cov report --summary-only 2>/dev/null || echo "Run 'make coverage' first"
bench:
cargo bench --bench tsp_benchmarks
examples:
@echo "=== Running TSP Benchmark Example ==="
cargo run --example tsp_benchmark --release
@echo ""
@echo "=== Running Model Persistence Example ==="
cargo run --example tsp_model_persistence --release
@echo ""
@echo "=== Running Algorithm Comparison Example ==="
cargo run --example tsp_algorithm_comparison --release
paper-bench:
@echo "=== Academic Paper Benchmarks ==="
@echo "Date: $$(date -Iseconds)"
@echo "Git SHA: $$(git rev-parse --short HEAD)"
@echo ""
cargo run --example tsp_benchmark --release 2>/dev/null
@echo ""
cargo run --example tsp_algorithm_comparison --release 2>/dev/null
train-berlin52:
cargo run --release -- train data/berlin52.tsp \
--algorithm aco \
--iterations 1000 \
--seed 42 \
--output models/berlin52_aco.apr
benchmark-model:
cargo run --release -- benchmark models/berlin52_aco.apr \
--instances data/berlin52.tsp data/eil51.tsp
clean:
cargo clean
rm -f models/*.apr
rm -f results/*.json
setup:
mkdir -p models results
help:
@echo "aprender-tsp Makefile"
@echo ""
@echo "Quality Gates:"
@echo " make test - Run all tests"
@echo " make lint - Run clippy lints"
@echo " make fmt - Format code"
@echo " make coverage - Generate coverage report"
@echo ""
@echo "Benchmarking:"
@echo " make bench - Run criterion benchmarks"
@echo " make paper-bench - Run benchmarks for academic papers"
@echo " make examples - Run all examples"
@echo ""
@echo "Training:"
@echo " make train-berlin52 - Train ACO on berlin52.tsp"
@echo " make benchmark-model - Benchmark trained model"
@echo ""
@echo "Maintenance:"
@echo " make clean - Clean build artifacts"
@echo " make setup - Create required directories"
tier1: fmt-check lint
tier2: tier1 test
tier3: tier2 coverage
ci: tier3 bench paper-bench