-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
181 lines (143 loc) · 4.88 KB
/
Makefile
File metadata and controls
181 lines (143 loc) · 4.88 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
# ================================================
# TEMM1E Makefile
# Cloud-native Rust AI agent runtime
# ================================================
CARGO := cargo
DOCKER := docker
BINARY := temm1e
VERSION := $(shell grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
GIT_SHA := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
IMAGE_TAG := $(VERSION)-$(GIT_SHA)
IMAGE_NAME := temm1e
# Cross-compilation targets
TARGETS := x86_64-unknown-linux-musl \
aarch64-unknown-linux-musl \
x86_64-apple-darwin \
aarch64-apple-darwin
# ------------------------------------------------
# Development
# ------------------------------------------------
.PHONY: build
build: ## Build debug binary
$(CARGO) build --workspace
.PHONY: build-release
build-release: ## Build optimised release binary
$(CARGO) build --release --bin $(BINARY)
.PHONY: run
run: ## Run the binary in debug mode
$(CARGO) run -- start
.PHONY: run-release
run-release: ## Run the release binary
$(CARGO) run --release -- start
.PHONY: test
test: ## Run all workspace tests
$(CARGO) test --workspace
.PHONY: test-verbose
test-verbose: ## Run tests with output
$(CARGO) test --workspace -- --nocapture
.PHONY: check
check: fmt-check clippy ## Run fmt check + clippy (CI gate)
.PHONY: fmt
fmt: ## Format all code
$(CARGO) fmt --all
.PHONY: fmt-check
fmt-check: ## Check formatting (no changes)
$(CARGO) fmt --all -- --check
.PHONY: clippy
clippy: ## Run clippy lints
$(CARGO) clippy --workspace --all-targets --all-features -- -D warnings
.PHONY: audit
audit: ## Run security audit
$(CARGO) audit
.PHONY: outdated
outdated: ## Check for outdated dependencies
$(CARGO) outdated --workspace --root-deps-only
.PHONY: doc
doc: ## Build documentation
$(CARGO) doc --workspace --no-deps --open
.PHONY: bench
bench: ## Run benchmarks
$(CARGO) bench --workspace
# ------------------------------------------------
# Docker
# ------------------------------------------------
.PHONY: docker-build
docker-build: ## Build Docker image
$(DOCKER) build -t $(IMAGE_NAME):$(IMAGE_TAG) -t $(IMAGE_NAME):latest .
.PHONY: docker-run
docker-run: ## Run Docker container
$(DOCKER) run --rm -it \
-p 8080:8080 \
-e TEMM1E_MODE=auto \
-e RUST_LOG=info \
$(IMAGE_NAME):latest
.PHONY: docker-compose-up
docker-compose-up: ## Start services with docker-compose
$(DOCKER) compose up -d
.PHONY: docker-compose-down
docker-compose-down: ## Stop docker-compose services
$(DOCKER) compose down
.PHONY: docker-push
docker-push: docker-build ## Push Docker image to GHCR
$(DOCKER) tag $(IMAGE_NAME):$(IMAGE_TAG) ghcr.io/temm1e/$(IMAGE_NAME):$(IMAGE_TAG)
$(DOCKER) push ghcr.io/temm1e/$(IMAGE_NAME):$(IMAGE_TAG)
# ------------------------------------------------
# Cross-compilation / Release
# ------------------------------------------------
.PHONY: release
release: ## Cross-compile release binaries for all targets
@echo "Building release binaries for all targets..."
@mkdir -p dist
@for target in $(TARGETS); do \
echo ""; \
echo "=== Building $$target ==="; \
if $(CARGO) build --release --target $$target --bin $(BINARY) 2>/dev/null; then \
cp target/$$target/release/$(BINARY) dist/$(BINARY)-$$target; \
echo "OK: dist/$(BINARY)-$$target"; \
else \
echo "SKIP: $$target (missing toolchain or linker)"; \
fi; \
done
@echo ""
@echo "=== Release binaries ==="
@ls -lh dist/ 2>/dev/null || echo "No binaries built."
.PHONY: release-checksums
release-checksums: release ## Generate SHA256 checksums for release binaries
@cd dist && shasum -a 256 $(BINARY)-* > checksums-sha256.txt
@cat dist/checksums-sha256.txt
# ------------------------------------------------
# Infrastructure
# ------------------------------------------------
.PHONY: tf-init
tf-init: ## Initialise Terraform
cd infrastructure/terraform && terraform init
.PHONY: tf-plan
tf-plan: ## Plan Terraform changes
cd infrastructure/terraform && terraform plan
.PHONY: tf-apply
tf-apply: ## Apply Terraform changes
cd infrastructure/terraform && terraform apply
.PHONY: fly-deploy
fly-deploy: ## Deploy to Fly.io
fly deploy -c infrastructure/terraform/fly.toml
# ------------------------------------------------
# Utilities
# ------------------------------------------------
.PHONY: clean
clean: ## Remove build artifacts
$(CARGO) clean
rm -rf dist/
.PHONY: clean-docker
clean-docker: ## Remove Docker images
$(DOCKER) rmi $(IMAGE_NAME):latest $(IMAGE_NAME):$(IMAGE_TAG) 2>/dev/null || true
.PHONY: install
install: build-release ## Install binary to ~/.cargo/bin
cp target/release/$(BINARY) $(HOME)/.cargo/bin/$(BINARY)
.PHONY: loc
loc: ## Count lines of code
@find crates src -name '*.rs' | xargs wc -l | tail -1
.PHONY: help
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-22s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help