-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
188 lines (154 loc) Β· 6.2 KB
/
Makefile
File metadata and controls
188 lines (154 loc) Β· 6.2 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# Bayesian SSH Makefile
# Provides common development and build tasks
.PHONY: help build test release clean install uninstall format lint check deps update-deps docs docs-serve docs-api demo-up demo-test demo-down demo-ssh-bastion demo-ssh-target1 demo-ssh-target2
# Configuration
BINARY_NAME = bayesian-ssh
CARGO = cargo
RUSTUP = rustup
TARGET_DIR = target
RELEASE_DIR = $(TARGET_DIR)/release
INSTALL_DIR = /usr/local/bin
# Default target
help: ## Show this help message
@echo "π Bayesian SSH - Available Commands"
@echo "====================================="
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
@echo ""
@echo "π Examples:"
@echo " make build # Build debug version"
@echo " make release # Build release version"
@echo " make test # Run all tests"
@echo " make install # Install to system"
@echo " make clean # Clean build artifacts"
# Build targets
build: ## Build debug version
@echo "π¨ Building debug version..."
$(CARGO) build
@echo "β
Build completed"
release: ## Build release version
@echo "π¨ Building release version..."
$(CARGO) build --release
@echo "β
Release build completed"
@echo "π Binary size: $(shell ls -lh $(RELEASE_DIR)/$(BINARY_NAME) 2>/dev/null | awk '{print $$5}' || echo "N/A")"
# Testing and quality
test: ## Run all tests
@echo "π§ͺ Running tests..."
$(CARGO) test
@echo "β
Tests completed"
check: ## Run cargo check
@echo "π Running cargo check..."
$(CARGO) check
@echo "β
Check completed"
format: ## Format code with rustfmt
@echo "π¨ Formatting code..."
$(CARGO) fmt --all
@echo "β
Formatting completed"
format-check: ## Check code formatting
@echo "π¨ Checking code formatting..."
$(CARGO) fmt --all -- --check
@echo "β
Formatting check completed"
lint: ## Run clippy linter
@echo "π Running clippy..."
$(CARGO) clippy -- -D warnings
@echo "β
Linting completed"
# Dependencies
deps: ## Install development dependencies
@echo "π¦ Installing development dependencies..."
$(RUSTUP) component add rustfmt
$(RUSTUP) component add clippy
@echo "β
Dependencies installed"
update-deps: ## Update Rust toolchain and dependencies
@echo "π Updating Rust toolchain..."
$(RUSTUP) update
@echo "π Updating Cargo dependencies..."
$(CARGO) update
@echo "β
Updates completed"
# Installation
install: release ## Install binary to system
@echo "π¦ Installing $(BINARY_NAME)..."
@if [ -f "$(RELEASE_DIR)/$(BINARY_NAME)" ]; then \
sudo cp "$(RELEASE_DIR)/$(BINARY_NAME)" "$(INSTALL_DIR)/$(BINARY_NAME)"; \
echo "β
$(BINARY_NAME) installed to $(INSTALL_DIR)"; \
else \
echo "β Release binary not found. Run 'make release' first."; \
exit 1; \
fi
uninstall: ## Remove binary from system
@echo "ποΈ Uninstalling $(BINARY_NAME)..."
@if [ -f "$(INSTALL_DIR)/$(BINARY_NAME)" ]; then \
sudo rm "$(INSTALL_DIR)/$(BINARY_NAME)"; \
echo "β
$(BINARY_NAME) uninstalled from $(INSTALL_DIR)"; \
else \
echo "βΉοΈ $(BINARY_NAME) not found in $(INSTALL_DIR)"; \
fi
# Development workflow
dev: format lint test ## Run full development workflow
@echo "π Development workflow completed!"
pre-commit: format lint test ## Run before committing
@echo "π Pre-commit checks passed!"
# Cleanup
clean: ## Clean build artifacts
@echo "π§Ή Cleaning build artifacts..."
$(CARGO) clean
@echo "β
Cleanup completed"
distclean: clean ## Deep clean (removes target and Cargo.lock)
@echo "π§Ή Deep cleaning..."
rm -rf $(TARGET_DIR)
rm -f Cargo.lock
@echo "β
Deep cleanup completed"
# Release management
version: ## Show current version
@echo "π Current version: $(shell grep '^version = ' Cargo.toml | cut -d'"' -f2)"
bump-patch: ## Bump patch version
@echo "π Bumping patch version..."
@./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}')
@echo "β
Version bumped"
bump-minor: ## Bump minor version
@echo "π Bumping minor version..."
@./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"}')
@echo "β
Version bumped"
bump-major: ## Bump major version
@echo "π Bumping major version..."
@./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"}')
@echo "β
Version bumped"
# Quick shortcuts
all: clean deps build test release ## Full build pipeline
@echo "π Full build pipeline completed!"
# ββ Demo Environment (Vagrant) ββββββββββββββββββββββββββββββ
demo-up: ## Boot the Vagrant demo VMs
@echo "π Starting demo VMs..."
@cd demo && vagrant up
demo-test: build ## Run integration tests against demo VMs
@echo "π§ͺ Running integration tests..."
@cd demo && bash test-all.sh --skip-build
demo-down: ## Destroy the Vagrant demo VMs
@echo "ποΈ Destroying demo VMs..."
@cd demo && vagrant destroy -f
demo-ssh-bastion: ## SSH into the bastion VM
@cd demo && vagrant ssh bastion
demo-ssh-target1: ## SSH into target1 VM
@cd demo && vagrant ssh target1
demo-ssh-target2: ## SSH into target2 VM
@cd demo && vagrant ssh target2
quick: build test ## Quick build and test
@echo "π Quick build and test completed!"
# Documentation
docs: ## Build documentation with mdBook
@echo "π Building documentation..."
mdbook build
@echo "β
Documentation built in docs/book/"
docs-serve: ## Serve documentation locally with live reload
@echo "π Serving documentation..."
mdbook serve --open
docs-api: ## Build Rust API documentation
@echo "π Building API documentation..."
$(CARGO) doc --no-deps --open
@echo "β
API documentation built"
# Show binary info
info: release ## Show binary information
@echo "π Binary Information:"
@echo " Location: $(RELEASE_DIR)/$(BINARY_NAME)"
@echo " Size: $(shell ls -lh $(RELEASE_DIR)/$(BINARY_NAME) 2>/dev/null | awk '{print $$5}' || echo "N/A")"
@echo " Version: $(shell grep '^version = ' Cargo.toml | cut -d'"' -f2)"
@echo " Build time: $(shell date)"