|
| 1 | +# Bayesian SSH Makefile |
| 2 | +# Provides common development and build tasks |
| 3 | + |
| 4 | +.PHONY: help build test release clean install uninstall format lint check deps update-deps |
| 5 | + |
| 6 | +# Configuration |
| 7 | +BINARY_NAME = bayesian-ssh |
| 8 | +CARGO = cargo |
| 9 | +RUSTUP = rustup |
| 10 | +TARGET_DIR = target |
| 11 | +RELEASE_DIR = $(TARGET_DIR)/release |
| 12 | +INSTALL_DIR = /usr/local/bin |
| 13 | + |
| 14 | +# Default target |
| 15 | +help: ## Show this help message |
| 16 | + @echo "🚀 Bayesian SSH - Available Commands" |
| 17 | + @echo "=====================================" |
| 18 | + @echo "" |
| 19 | + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}' |
| 20 | + @echo "" |
| 21 | + @echo "📚 Examples:" |
| 22 | + @echo " make build # Build debug version" |
| 23 | + @echo " make release # Build release version" |
| 24 | + @echo " make test # Run all tests" |
| 25 | + @echo " make install # Install to system" |
| 26 | + @echo " make clean # Clean build artifacts" |
| 27 | + |
| 28 | +# Build targets |
| 29 | +build: ## Build debug version |
| 30 | + @echo "🔨 Building debug version..." |
| 31 | + $(CARGO) build |
| 32 | + @echo "✅ Build completed" |
| 33 | + |
| 34 | +release: ## Build release version |
| 35 | + @echo "🔨 Building release version..." |
| 36 | + $(CARGO) build --release |
| 37 | + @echo "✅ Release build completed" |
| 38 | + @echo "📊 Binary size: $(shell ls -lh $(RELEASE_DIR)/$(BINARY_NAME) 2>/dev/null | awk '{print $$5}' || echo "N/A")" |
| 39 | + |
| 40 | +# Testing and quality |
| 41 | +test: ## Run all tests |
| 42 | + @echo "🧪 Running tests..." |
| 43 | + $(CARGO) test |
| 44 | + @echo "✅ Tests completed" |
| 45 | + |
| 46 | +check: ## Run cargo check |
| 47 | + @echo "🔍 Running cargo check..." |
| 48 | + $(CARGO) check |
| 49 | + @echo "✅ Check completed" |
| 50 | + |
| 51 | +format: ## Format code with rustfmt |
| 52 | + @echo "🎨 Formatting code..." |
| 53 | + $(CARGO) fmt --all |
| 54 | + @echo "✅ Formatting completed" |
| 55 | + |
| 56 | +format-check: ## Check code formatting |
| 57 | + @echo "🎨 Checking code formatting..." |
| 58 | + $(CARGO) fmt --all -- --check |
| 59 | + @echo "✅ Formatting check completed" |
| 60 | + |
| 61 | +lint: ## Run clippy linter |
| 62 | + @echo "🔍 Running clippy..." |
| 63 | + $(CARGO) clippy -- -D warnings |
| 64 | + @echo "✅ Linting completed" |
| 65 | + |
| 66 | +# Dependencies |
| 67 | +deps: ## Install development dependencies |
| 68 | + @echo "📦 Installing development dependencies..." |
| 69 | + $(RUSTUP) component add rustfmt |
| 70 | + $(RUSTUP) component add clippy |
| 71 | + @echo "✅ Dependencies installed" |
| 72 | + |
| 73 | +update-deps: ## Update Rust toolchain and dependencies |
| 74 | + @echo "🔄 Updating Rust toolchain..." |
| 75 | + $(RUSTUP) update |
| 76 | + @echo "🔄 Updating Cargo dependencies..." |
| 77 | + $(CARGO) update |
| 78 | + @echo "✅ Updates completed" |
| 79 | + |
| 80 | +# Installation |
| 81 | +install: release ## Install binary to system |
| 82 | + @echo "📦 Installing $(BINARY_NAME)..." |
| 83 | + @if [ -f "$(RELEASE_DIR)/$(BINARY_NAME)" ]; then \ |
| 84 | + sudo cp "$(RELEASE_DIR)/$(BINARY_NAME)" "$(INSTALL_DIR)/$(BINARY_NAME)"; \ |
| 85 | + echo "✅ $(BINARY_NAME) installed to $(INSTALL_DIR)"; \ |
| 86 | + else \ |
| 87 | + echo "❌ Release binary not found. Run 'make release' first."; \ |
| 88 | + exit 1; \ |
| 89 | + fi |
| 90 | + |
| 91 | +uninstall: ## Remove binary from system |
| 92 | + @echo "🗑️ Uninstalling $(BINARY_NAME)..." |
| 93 | + @if [ -f "$(INSTALL_DIR)/$(BINARY_NAME)" ]; then \ |
| 94 | + sudo rm "$(INSTALL_DIR)/$(BINARY_NAME)"; \ |
| 95 | + echo "✅ $(BINARY_NAME) uninstalled from $(INSTALL_DIR)"; \ |
| 96 | + else \ |
| 97 | + echo "ℹ️ $(BINARY_NAME) not found in $(INSTALL_DIR)"; \ |
| 98 | + fi |
| 99 | + |
| 100 | +# Development workflow |
| 101 | +dev: format lint test ## Run full development workflow |
| 102 | + @echo "🎉 Development workflow completed!" |
| 103 | + |
| 104 | +pre-commit: format lint test ## Run before committing |
| 105 | + @echo "🎉 Pre-commit checks passed!" |
| 106 | + |
| 107 | +# Cleanup |
| 108 | +clean: ## Clean build artifacts |
| 109 | + @echo "🧹 Cleaning build artifacts..." |
| 110 | + $(CARGO) clean |
| 111 | + @echo "✅ Cleanup completed" |
| 112 | + |
| 113 | +distclean: clean ## Deep clean (removes target and Cargo.lock) |
| 114 | + @echo "🧹 Deep cleaning..." |
| 115 | + rm -rf $(TARGET_DIR) |
| 116 | + rm -f Cargo.lock |
| 117 | + @echo "✅ Deep cleanup completed" |
| 118 | + |
| 119 | +# Release management |
| 120 | +version: ## Show current version |
| 121 | + @echo "📋 Current version: $(shell grep '^version = ' Cargo.toml | cut -d'"' -f2)" |
| 122 | + |
| 123 | +bump-patch: ## Bump patch version |
| 124 | + @echo "🔄 Bumping patch version..." |
| 125 | + @./scripts/build_and_push.sh --version $(shell ./scripts/build_and_push.sh --version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | awk -F. '{print $$1"."$$2"."$$3+1}') |
| 126 | + @echo "✅ Version bumped" |
| 127 | + |
| 128 | +bump-minor: ## Bump minor version |
| 129 | + @echo "🔄 Bumping minor version..." |
| 130 | + @./scripts/build_and_push.sh --version $(shell ./scripts/build_and_push.sh --version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | awk -F. '{print $$1"."$$2+1".0"}') |
| 131 | + @echo "✅ Version bumped" |
| 132 | + |
| 133 | +bump-major: ## Bump major version |
| 134 | + @echo "🔄 Bumping major version..." |
| 135 | + @./scripts/build_and_push.sh --version $(shell ./scripts/build_and_push.sh --version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | awk -F. '{print $$1+1".0.0"}') |
| 136 | + @echo "✅ Version bumped" |
| 137 | + |
| 138 | +# Quick shortcuts |
| 139 | +all: clean deps build test release ## Full build pipeline |
| 140 | + @echo "🎉 Full build pipeline completed!" |
| 141 | + |
| 142 | +quick: build test ## Quick build and test |
| 143 | + @echo "🎉 Quick build and test completed!" |
| 144 | + |
| 145 | +# Documentation |
| 146 | +docs: ## Build documentation |
| 147 | + @echo "📚 Building documentation..." |
| 148 | + $(CARGO) doc --no-deps --open |
| 149 | + @echo "✅ Documentation built" |
| 150 | + |
| 151 | +# Show binary info |
| 152 | +info: release ## Show binary information |
| 153 | + @echo "📊 Binary Information:" |
| 154 | + @echo " Location: $(RELEASE_DIR)/$(BINARY_NAME)" |
| 155 | + @echo " Size: $(shell ls -lh $(RELEASE_DIR)/$(BINARY_NAME) 2>/dev/null | awk '{print $$5}' || echo "N/A")" |
| 156 | + @echo " Version: $(shell grep '^version = ' Cargo.toml | cut -d'"' -f2)" |
| 157 | + @echo " Build time: $(shell date)" |
0 commit comments