-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
110 lines (90 loc) · 3.85 KB
/
Copy pathMakefile
File metadata and controls
110 lines (90 loc) · 3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# Commit-AI Makefile
.PHONY: build build-prod build-all test test-coverage clean run run-verbose lint fmt deps update-deps check release install-local help
# Variables
BINARY_NAME=commit-ai
BIN_DIR=bin
DIST_DIR=dist
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "v1.2.0")
BUILD_DATE=$(shell date -u '+%Y-%m-%d %H:%M:%S')
GIT_COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
CARGO_ENV=COMMIT_AI_BUILD_DATE="$(BUILD_DATE)" COMMIT_AI_GIT_COMMIT="$(GIT_COMMIT)"
help: ## Show this help message
@echo "Commit-AI - Development Commands"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
build: ## Build the binary for development
@echo "Building $(BINARY_NAME) for development..."
@$(CARGO_ENV) cargo build
@echo "✓ Built: target/debug/$(BINARY_NAME)"
build-prod: ## Build production binary to bin/
@echo "Building $(BINARY_NAME) for production (version=$(VERSION))..."
@mkdir -p $(BIN_DIR)
@$(CARGO_ENV) cargo build --release
@cp target/release/$(BINARY_NAME).exe $(BIN_DIR)/$(BINARY_NAME).exe 2>/dev/null || \
cp target/release/$(BINARY_NAME) $(BIN_DIR)/$(BINARY_NAME) 2>/dev/null || true
@echo "[OK] Built: $(BIN_DIR)/$(BINARY_NAME)"
build-all: ## Build for all platforms (requires cross toolchains)
@echo "Building for all platforms (version=$(VERSION))..."
@mkdir -p $(DIST_DIR)
@echo " → Windows (amd64)..."
@$(CARGO_ENV) cargo build --release --target x86_64-pc-windows-gnu
@cp target/x86_64-pc-windows-gnu/release/$(BINARY_NAME).exe $(DIST_DIR)/$(BINARY_NAME)-windows-amd64.exe
@echo " → Linux (amd64)..."
@$(CARGO_ENV) cargo build --release --target x86_64-unknown-linux-gnu
@cp target/x86_64-unknown-linux-gnu/release/$(BINARY_NAME) $(DIST_DIR)/$(BINARY_NAME)-linux-amd64
@echo " → Linux (arm64)..."
@$(CARGO_ENV) cargo build --release --target aarch64-unknown-linux-gnu
@cp target/aarch64-unknown-linux-gnu/release/$(BINARY_NAME) $(DIST_DIR)/$(BINARY_NAME)-linux-arm64
@echo " → macOS (amd64)..."
@$(CARGO_ENV) cargo build --release --target x86_64-apple-darwin
@cp target/x86_64-apple-darwin/release/$(BINARY_NAME) $(DIST_DIR)/$(BINARY_NAME)-darwin-amd64
@echo " → macOS (arm64)..."
@$(CARGO_ENV) cargo build --release --target aarch64-apple-darwin
@cp target/aarch64-apple-darwin/release/$(BINARY_NAME) $(DIST_DIR)/$(BINARY_NAME)-darwin-arm64
@echo "[OK] All builds complete in $(DIST_DIR)/"
test: ## Run tests
@echo "Running tests..."
@cargo test -- --test-output immediate
test-coverage: ## Run tests with coverage (requires cargo-llvm-cov)
@echo "Running tests with coverage..."
@cargo llvm-cov --html --open
lint: ## Run clippy linter
@echo "Running clippy..."
@cargo clippy -- -D warnings
fmt: ## Format code
@echo "Formatting code..."
@cargo fmt
@echo "✓ Code formatted"
clean: ## Clean build artifacts
@echo "Cleaning..."
@cargo clean
@rm -rf $(DIST_DIR)
@echo "[OK] Cleaned"
clean-all: clean ## Clean everything including bin/
@rm -rf $(BIN_DIR)
@echo "[OK] Cleaned all"
run: build ## Build and run
@$(CARGO_ENV) cargo run
run-verbose: build ## Build and run with verbose output
@$(CARGO_ENV) cargo run -- -v
deps: ## Fetch/verify dependencies
@echo "Fetching dependencies..."
@cargo fetch
@echo "✓ Dependencies ready"
update-deps: ## Update all dependencies
@echo "Updating dependencies..."
@cargo update
@echo "✓ Dependencies updated"
check: fmt test lint ## Run format, tests, and lint
@echo "✓ All checks passed"
release: clean test build-prod build-all ## Prepare full release
@echo ""
@echo "[OK] Release ready!"
@echo " Version: $(VERSION)"
@echo " Production: $(BIN_DIR)/"
@echo " Platforms: $(DIST_DIR)/"
install-local: ## Install to ~/.cargo/bin
@echo "Installing locally..."
@$(CARGO_ENV) cargo install --path .
@echo "✓ Installed"
.DEFAULT_GOAL := help