.PHONY: help build test clean check format lint docs examples publish-dry publish-real release setup git-commit
help:
@echo "๐ Rust Rule Engine - Makefile Commands"
@echo "======================================="
@echo ""
@echo "๐ฆ Build & Test:"
@echo " make build - Build the project"
@echo " make test - Run all tests"
@echo " make examples - Run all examples"
@echo " make check - Run cargo check"
@echo ""
@echo "๐ง Code Quality:"
@echo " make format - Format code with rustfmt"
@echo " make lint - Run clippy lints"
@echo " make docs - Generate documentation"
@echo ""
@echo "๐ Git & Publishing:"
@echo " make git-commit - Add all files and commit"
@echo " make publish-dry - Dry run publish (test only)"
@echo " make publish - Publish to crates.io"
@echo " make release - Full release process"
@echo ""
@echo "๐งน Cleanup:"
@echo " make clean - Clean build artifacts"
@echo ""
build:
@echo "๐จ Building rust-rule-engine..."
cargo build
build-release:
@echo "๐จ Building rust-rule-engine (release)..."
cargo build --release
test:
@echo "๐งช Running tests..."
cargo test
bench:
@echo "โก Running benchmarks..."
cargo bench
bench-baseline:
@echo "โก Running benchmarks with baseline..."
cargo bench -- --save-baseline main
bench-compare:
@echo "โก Comparing benchmarks..."
cargo bench -- --baseline main
bench-report:
@echo "๐ Opening benchmark report..."
@if [ -f target/criterion/index.html ]; then \
echo "๐ Opening benchmark report in browser..."; \
xdg-open target/criterion/index.html 2>/dev/null || open target/criterion/index.html 2>/dev/null || echo "Please open target/criterion/index.html manually"; \
else \
echo "โ No benchmark report found. Run 'make bench' first."; \
fi
examples:
@echo "๐ฏ Running all examples..."
@echo "================================"
@for example in ecommerce fraud_detection grule_demo method_calls_demo rule_file_functions_demo custom_functions_demo; do \
echo ""; \
echo "๐ Running example: $$example"; \
echo "----------------------------"; \
cargo run --example $$example || true; \
echo ""; \
done
check:
@echo "โ
Checking project..."
cargo check
format:
@echo "๐จ Formatting code..."
cargo fmt
lint:
@echo "๐ Running clippy lints..."
cargo clippy -- -D warnings
docs:
@echo "๐ Generating documentation..."
cargo doc --open
clean:
@echo "๐งน Cleaning build artifacts..."
cargo clean
git-status:
@echo "๐ Git status:"
git status --short
git-add:
@echo "โ Adding all files to git..."
git add .
git-commit: git-add
@echo "๐พ Committing changes..."
@read -p "Enter commit message: " msg; \
git commit -m "$$msg"
pre-publish: format lint test
@echo "๐ Pre-publish checks completed successfully!"
publish-dry: pre-publish
@echo "๐งช Dry run publish to crates.io..."
@echo "โ ๏ธ This will test the publish process without actually publishing"
@echo ""
@echo "๐ Package info:"
@grep "^name\|^version\|^description" Cargo.toml
@echo ""
@echo "๐ Files to be included:"
@cargo package --list | head -20
@echo ""
@read -p "Continue with dry run? (y/N): " confirm; \
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
cargo publish --dry-run --allow-dirty; \
else \
echo "โ Dry run cancelled"; \
fi
publish: pre-publish git-status
@echo "๐ Publishing to crates.io..."
@echo "โ ๏ธ This will ACTUALLY publish the crate!"
@echo ""
@echo "๐ Package info:"
@grep "^name\|^version\|^description" Cargo.toml
@echo ""
@echo "๐ Git status:"
@git status --short
@echo ""
@if [ -n "$$(git status --porcelain)" ]; then \
echo "โ ๏ธ Warning: You have uncommitted changes!"; \
echo "Run 'make git-commit' first or use --allow-dirty"; \
echo ""; \
read -p "Publish with uncommitted changes? (y/N): " dirty; \
if [ "$$dirty" = "y" ] || [ "$$dirty" = "Y" ]; then \
echo "Publishing with --allow-dirty..."; \
cargo publish --allow-dirty; \
else \
echo "โ Publish cancelled. Commit your changes first."; \
exit 1; \
fi; \
else \
read -p "Continue with publish? (y/N): " confirm; \
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
cargo publish; \
else \
echo "โ Publish cancelled"; \
fi; \
fi
release:
@echo "๐ Starting full release process..."
@echo "=================================="
@echo ""
@echo "This will:"
@echo "1. ๐จ Format code"
@echo "2. ๐ Run lints"
@echo "3. ๐งช Run tests"
@echo "4. ๐ฏ Run examples"
@echo "5. ๐พ Commit changes (if needed)"
@echo "6. ๐ Publish to crates.io"
@echo ""
@read -p "Continue with full release? (y/N): " confirm; \
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
$(MAKE) format; \
$(MAKE) lint; \
$(MAKE) test; \
$(MAKE) examples; \
if [ -n "$$(git status --porcelain)" ]; then \
echo ""; \
echo "๐พ Changes detected, committing..."; \
$(MAKE) git-commit; \
fi; \
echo ""; \
echo "๐ Ready to publish!"; \
$(MAKE) publish-real; \
else \
echo "โ Release cancelled"; \
fi
setup:
@echo "๐ง Setting up development environment..."
@echo "Installing required tools..."
rustup component add rustfmt clippy
@echo "โ
Setup complete!"
version-patch:
@echo "๐ Bumping patch version..."
@current=$$(grep "^version" Cargo.toml | cut -d'"' -f2); \
echo "Current version: $$current"; \
read -p "Enter new patch version (e.g., 0.1.1): " new_version; \
sed -i 's/^version = ".*"/version = "'$$new_version'"/' Cargo.toml; \
echo "โ
Version updated to $$new_version"
version-minor:
@echo "๐ Bumping minor version..."
@current=$$(grep "^version" Cargo.toml | cut -d'"' -f2); \
echo "Current version: $$current"; \
read -p "Enter new minor version (e.g., 0.2.0): " new_version; \
sed -i 's/^version = ".*"/version = "'$$new_version'"/' Cargo.toml; \
echo "โ
Version updated to $$new_version"
version-major:
@echo "๐ Bumping major version..."
@current=$$(grep "^version" Cargo.toml | cut -d'"' -f2); \
echo "Current version: $$current"; \
read -p "Enter new major version (e.g., 1.0.0): " new_version; \
sed -i 's/^version = ".*"/version = "'$$new_version'"/' Cargo.toml; \
echo "โ
Version updated to $$new_version"
package-info:
@echo "๐ฆ Package Information"
@echo "====================="
@echo ""
@echo "๐ Basic Info:"
@grep "^name\|^version\|^description\|^authors" Cargo.toml
@echo ""
@echo "๐ Files to be packaged:"
@cargo package --list 2>/dev/null | head -20 || echo "Run 'cargo check' first"
@echo ""
@echo "๐ Package size:"
@cargo package --list 2>/dev/null | wc -l || echo "Run 'cargo check' first"
@echo " files total"
qa: format lint test
@echo "โ
All quality assurance checks passed!"