.PHONY: all build check test lint fmt doc clean install bench ci help setup
all: build
setup: build model-download
@echo ""
@echo "✓ Setup complete!"
@echo " Binary: target/release/m2m"
@echo " Model: ./models/hydra/model.safetensors"
@echo ""
@echo "Try: cargo test test_load_hydra_model -- --ignored --nocapture"
build:
cargo build --release --features crypto
build-debug:
cargo build --features crypto
build-minimal:
cargo build --release
install:
cargo install --path . --features crypto
check: fmt-check lint test doc-check
@echo "✓ All checks passed"
ci: fmt-check lint-strict test-all doc-check audit
@echo "✓ CI checks passed"
fmt-check:
cargo fmt --all -- --check
fmt:
cargo fmt --all
lint:
cargo clippy --all-targets --all-features -- -D warnings
lint-strict:
cargo clippy --all-targets --all-features -- \
-D warnings \
-D clippy::pedantic \
-D clippy::nursery \
-A clippy::module_name_repetitions \
-A clippy::must_use_candidate \
-A clippy::missing_errors_doc \
-A clippy::missing_panics_doc \
-A clippy::doc_markdown
lint-fix:
cargo clippy --all-targets --all-features --fix --allow-dirty
test:
cargo test --features crypto
test-all:
cargo test --features crypto -- --include-ignored
test-verbose:
cargo test --features crypto -- --nocapture
test-one:
@read -p "Test name: " name; \
cargo test --features crypto $$name -- --nocapture
bench:
cargo bench
bench-algorithms:
cargo run --release --bin benchmark --features crypto
bench-tokens:
cargo run --release --bin token_benchmark --features crypto
bench-token-native:
cargo run --release --bin token_native_benchmark --features crypto
stress-test:
cargo run --release --bin m2m_stress_test --features crypto -- --quick
stress-test-full:
cargo run --release --bin m2m_stress_test --features crypto
coverage:
cargo tarpaulin --features crypto --out Html --output-dir target/coverage
@echo "Coverage report: target/coverage/tarpaulin-report.html"
doc:
cargo doc --no-deps --all-features
doc-open:
cargo doc --no-deps --all-features --open
doc-check:
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
audit:
cargo audit
outdated:
cargo outdated
update:
cargo update
udeps:
cargo +nightly udeps --all-targets
release-check: ci
@echo ""
@echo "Release checklist:"
@echo " 1. Update version in Cargo.toml"
@echo " 2. Update CHANGELOG.md"
@echo " 3. Run: make release-build"
@echo " 4. Run: cargo publish --dry-run"
release-build:
cargo build --release
@echo "Binary: target/release/m2m"
@ls -lh target/release/m2m 2>/dev/null || true
publish-dry:
cargo publish --dry-run
publish:
cargo publish
watch:
cargo watch -x test
watch-lint:
cargo watch -x clippy
run-server:
RUST_LOG=info cargo run -- server --port 8080
run-proxy:
RUST_LOG=info cargo run -- proxy --upstream https://openrouter.ai/api/v1
tree:
cargo tree
bloat:
cargo bloat --release --crates
flamegraph:
cargo flamegraph --bin m2m -- compress '{"test": true}'
clean:
cargo clean
rebuild: clean build
distclean: clean
rm -rf target/
rm -f Cargo.lock
model-download:
@mkdir -p models/hydra
huggingface-cli download infernet/hydra --local-dir ./models/hydra
@echo "Downloading Llama 3 tokenizer..."
@curl -sL "https://huggingface.co/NousResearch/Meta-Llama-3.1-8B/resolve/main/tokenizer.json" -o ./models/hydra/tokenizer.json
@echo "✓ Model and tokenizer downloaded to ./models/hydra"
@ls -la ./models/hydra/
tokenizer-download:
@mkdir -p models/hydra
@echo "Downloading Llama 3 tokenizer..."
curl -sL "https://huggingface.co/NousResearch/Meta-Llama-3.1-8B/resolve/main/tokenizer.json" -o ./models/hydra/tokenizer.json
@echo "✓ Tokenizer downloaded to ./models/hydra/tokenizer.json"
model-verify:
@echo "Checking model files..."
@test -f ./models/hydra/model.safetensors && echo "✓ model.safetensors found" || echo "✗ model.safetensors not found"
@test -f ./models/hydra/tokenizer.json && echo "✓ tokenizer.json found" || echo "✗ tokenizer.json not found (run: make tokenizer-download)"
help:
@echo "M2M Protocol - Makefile Commands"
@echo ""
@echo "Quick Start:"
@echo " make setup - Build + download Hydra model (recommended)"
@echo ""
@echo "Build:"
@echo " make build - Build release binary (with crypto)"
@echo " make build-minimal- Build without crypto feature"
@echo " make install - Install to ~/.cargo/bin"
@echo ""
@echo "Quality:"
@echo " make check - Run all quality checks"
@echo " make ci - Run CI checks (stricter)"
@echo " make fmt - Format code"
@echo " make lint - Run clippy"
@echo " make lint-strict - Run clippy with pedantic lints"
@echo ""
@echo "Testing:"
@echo " make test - Run tests"
@echo " make test-all - Run all tests (including integration)"
@echo " make coverage - Generate coverage report"
@echo ""
@echo "Benchmarks:"
@echo " make bench-algorithms - Run compression algorithm benchmarks"
@echo " make bench-tokens - Run token benchmarks"
@echo " make bench-token-native- Run TokenNative benchmarks"
@echo " make stress-test - Run stress test (quick mode)"
@echo " make stress-test-full - Run stress test (full mode)"
@echo ""
@echo "Documentation:"
@echo " make doc - Build documentation"
@echo " make doc-open - Build and open documentation"
@echo ""
@echo "Security:"
@echo " make audit - Security audit dependencies"
@echo " make outdated - Check for outdated dependencies"
@echo ""
@echo "Hydra Model:"
@echo " make model-download - Download from HuggingFace"
@echo ""
@echo "Development:"
@echo " make watch - Watch and run tests"
@echo " make run-server - Start development server"
@echo " make run-proxy - Start development proxy"
@echo ""
@echo "Cleanup:"
@echo " make clean - Clean build artifacts"
@echo " make distclean - Remove all generated files"