-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
282 lines (243 loc) · 9.11 KB
/
Makefile
File metadata and controls
282 lines (243 loc) · 9.11 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
.PHONY: build install test clean lint fmt vet help build-all package-all dev-setup dev-install dev-test dev-clean dev-rebuild fish-setup fish-functions fish-info dev-quick-setup dev-env version rc release push
# Build variables
BINARY_NAME=aim
VERSION?=$(shell cat VERSION 2>/dev/null || echo "0.1.3-rc1")
GIT_COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS=-ldflags "-X github.com/fakecore/aim/internal/cmd.Version=$(VERSION) \
-X github.com/fakecore/aim/internal/cmd.GitCommit=$(GIT_COMMIT) \
-X github.com/fakecore/aim/internal/cmd.BuildDate=$(BUILD_DATE)" \
-trimpath
# Directories
BIN_DIR=bin
CMD_DIR=cmd
# Development environment
DEV_HOME=/tmp/aim-dev
DEV_BIN=$(DEV_HOME)/bin
DEV_CONFIG=$(DEV_HOME)/config
DEV_CACHE=$(DEV_HOME)/cache
# Default target
all: build
## help: Display this help message
help:
@echo "AIM - AI Interface Manager"
@echo ""
@echo "Available targets:"
@grep -E '^## ' Makefile | sed 's/## / /'
@echo ""
## build: Build the binaries
build:
@echo "Building $(BINARY_NAME)..."
@mkdir -p $(BIN_DIR)
@go build $(LDFLAGS) -o $(BIN_DIR)/$(BINARY_NAME) ./$(CMD_DIR)/aim
@echo "Build complete: $(BIN_DIR)/$(BINARY_NAME)"
## install: Install to /usr/local/bin (system-wide, from local build)
install: build
@./scripts/setup-tool.sh install --local --force
## uninstall: Uninstall from /usr/local/bin
uninstall:
@./scripts/setup-tool.sh uninstall --force
## test: Run tests
test:
@echo "Running tests..."
@go test -v -race -coverprofile=coverage.out ./...
@echo "Tests complete"
## clean: Remove build artifacts
clean:
@echo "Cleaning build artifacts..."
@rm -rf $(BIN_DIR)
@rm -f coverage.out
@go clean
@echo "Clean complete"
## coverage: Show test coverage
coverage: test
@go tool cover -html=coverage.out
## lint: Run linters
lint:
@echo "Running linters..."
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run ./...; \
else \
echo "golangci-lint not installed. Install from https://golangci-lint.run/"; \
fi
## fmt: Format code
fmt:
@echo "Formatting code..."
@go fmt ./...
@echo "Formatting complete"
## vet: Run go vet
vet:
@echo "Running go vet..."
@go vet ./...
@echo "Vet complete"
## mod: Download and tidy dependencies
mod:
@echo "Downloading dependencies..."
@go mod download
@go mod tidy
@echo "Dependencies updated"
## build-all: Build for all platforms
build-all:
@echo "Building for all platforms..."
@mkdir -p $(BIN_DIR)
@echo "Building for Linux AMD64..."
@GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o $(BIN_DIR)/$(BINARY_NAME)-linux-amd64 ./$(CMD_DIR)/aim
@echo "Building for Linux ARM64..."
@GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o $(BIN_DIR)/$(BINARY_NAME)-linux-arm64 ./$(CMD_DIR)/aim
@echo "Building for macOS AMD64..."
@GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o $(BIN_DIR)/$(BINARY_NAME)-darwin-amd64 ./$(CMD_DIR)/aim
@echo "Building for macOS ARM64..."
@GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o $(BIN_DIR)/$(BINARY_NAME)-darwin-arm64 ./$(CMD_DIR)/aim
@echo "Cross-platform build complete"
## package-all: Create tar.gz packages for all platforms
package-all: build-all
@echo "Creating tar.gz packages..."
@mkdir -p $(BIN_DIR)/packages
@echo "Packaging for Linux AMD64..."
@mkdir -p $(BIN_DIR)/packages/$(BINARY_NAME)-linux-amd64
@cp $(BIN_DIR)/$(BINARY_NAME)-linux-amd64 $(BIN_DIR)/packages/$(BINARY_NAME)-linux-amd64/aim
@cd $(BIN_DIR)/packages && tar -czf $(BINARY_NAME)-linux-amd64.tar.gz $(BINARY_NAME)-linux-amd64
@echo "Packaging for Linux ARM64..."
@mkdir -p $(BIN_DIR)/packages/$(BINARY_NAME)-linux-arm64
@cp $(BIN_DIR)/$(BINARY_NAME)-linux-arm64 $(BIN_DIR)/packages/$(BINARY_NAME)-linux-arm64/aim
@cd $(BIN_DIR)/packages && tar -czf $(BINARY_NAME)-linux-arm64.tar.gz $(BINARY_NAME)-linux-arm64
@echo "Packaging for macOS AMD64..."
@mkdir -p $(BIN_DIR)/packages/$(BINARY_NAME)-darwin-amd64
@cp $(BIN_DIR)/$(BINARY_NAME)-darwin-amd64 $(BIN_DIR)/packages/$(BINARY_NAME)-darwin-amd64/aim
@cd $(BIN_DIR)/packages && tar -czf $(BINARY_NAME)-darwin-amd64.tar.gz $(BINARY_NAME)-darwin-amd64
@echo "Packaging for macOS ARM64..."
@mkdir -p $(BIN_DIR)/packages/$(BINARY_NAME)-darwin-arm64
@cp $(BIN_DIR)/$(BINARY_NAME)-darwin-arm64 $(BIN_DIR)/packages/$(BINARY_NAME)-darwin-arm64/aim
@cd $(BIN_DIR)/packages && tar -czf $(BINARY_NAME)-darwin-arm64.tar.gz $(BINARY_NAME)-darwin-arm64
@echo "Packaging complete"
@ls -la $(BIN_DIR)/packages/*.tar.gz
## run: Build and run aim
run: build
@./$(BIN_DIR)/$(BINARY_NAME)
## check: Run all checks (fmt, vet, lint, test)
check: fmt vet lint test
@echo "All checks passed"
## dev-setup: Setup development environment
dev-setup:
@echo "Setting up dev environment at $(DEV_HOME)"
@mkdir -p $(DEV_BIN) $(DEV_CONFIG) $(DEV_CACHE)
@echo "✓ Created $(DEV_HOME)"
@echo ""
@echo "Add to your shell rc file:"
@echo " export PATH=\"$(DEV_BIN):\$$PATH\""
@echo " export AIM_HOME=$(DEV_HOME)"
@echo ""
@echo "Or run for current session:"
@echo " export PATH=\"$(DEV_BIN):\$$PATH\" && export AIM_HOME=$(DEV_HOME)"
## dev-install: Build and install to dev environment
dev-install: build
@echo "Installing to dev environment..."
@cp $(BIN_DIR)/aim $(DEV_BIN)/
@chmod +x $(DEV_BIN)/aim
@echo "✓ Installed to $(DEV_BIN)"
@echo ""
@echo "Binaries:"
@ls -lh $(DEV_BIN)/
## dev-test: Run in dev environment
dev-test: dev-install
@echo "Testing dev installation..."
@echo ""
@echo "==> aim version"
@$(DEV_BIN)/aim version
@echo ""
@echo "==> Symlinks"
@ls -la $(DEV_BIN)/ | grep -E '(aim)'
## dev-rebuild: Quick rebuild and install
dev-rebuild:
@make -s clean
@make -s build
@make -s dev-install
## dev-clean: Clean dev environment
dev-clean:
@echo "Cleaning dev environment..."
@rm -rf $(DEV_HOME)
@echo "✓ Cleaned $(DEV_HOME)"
## fish-setup: Complete setup for Fish shell users
fish-setup: dev-setup dev-install fish-functions
@echo ""
@echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
@echo "✓ Fish shell setup complete!"
@echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
@echo ""
@echo "Next steps:"
@echo " 1. Run: source ~/.config/fish/config.fish"
@echo " 2. Run: aim-dev"
@echo " 3. Test: aim version"
@echo ""
@echo "Or just restart your Fish shell!"
@echo ""
## fish-functions: Create Fish functions for development
fish-functions:
@./scripts/setup-fish-functions.sh
## fish-info: Show Fish shell integration status
fish-info:
@echo "Fish Shell Integration Status"
@echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
@echo ""
@echo "Functions:"
@test -f ~/.config/fish/functions/aim-dev.fish && echo " ✓ aim-dev" || echo " ✗ aim-dev"
@test -f ~/.config/fish/functions/aim-rebuild.fish && echo " ✓ aim-rebuild" || echo " ✗ aim-rebuild"
@test -f ~/.config/fish/functions/aim-test.fish && echo " ✓ aim-test" || echo " ✗ aim-test"
@test -f ~/.config/fish/functions/aim-clean.fish && echo " ✓ aim-clean" || echo " ✗ aim-clean"
@test -f ~/.config/fish/functions/aim-info.fish && echo " ✓ aim-info" || echo " ✗ aim-info"
@echo ""
@echo "Dev Environment:"
@test -d $(DEV_HOME) && echo " ✓ $(DEV_HOME)" || echo " ✗ $(DEV_HOME) (not created)"
@test -f $(DEV_BIN)/aim && echo " ✓ aim binary" || echo " ✗ aim binary"
@echo ""
@echo "To setup: make fish-setup"
## version: Show current version information
version:
@echo "Current version information:"
@echo "=========================="
@./scripts/release.sh current
## rc: Create a Release Candidate (RC) version (commits only)
rc:
@echo "Creating Release Candidate..."
@./scripts/release.sh rc
## release: Create a final release version (commits only)
release:
@echo "Creating final release..."
@./scripts/release.sh release
## push: Push commits and tags to remote repository
push:
@echo "Pushing commits and tags to remote..."
@./scripts/release.sh push
## rc-dry: Preview RC version creation without executing
rc-dry:
@echo "Previewing Release Candidate creation..."
@./scripts/release.sh rc --dry-run
## release-dry: Preview release version creation without executing
release-dry:
@echo "Previewing final release creation..."
@./scripts/release.sh release --dry-run
## push-dry: Preview push operation without executing
push-dry:
@echo "Previewing push operation..."
@./scripts/release.sh push --dry-run
## version-set: Set specific version (for manual version control)
version-set:
@if [ -z "$(VERSION)" ]; then \
echo "Usage: make version-set VERSION=1.2.3"; \
exit 1; \
fi
@echo "Setting version to $(VERSION)..."
@echo "$(VERSION)" > VERSION
@echo "Version updated to $(VERSION)"
## version-patch: Increment patch version (1.2.3 -> 1.2.4)
version-patch:
@echo "Incrementing patch version..."
@./scripts/release.sh patch --dry-run
## version-minor: Increment minor version (1.2.3 -> 1.3.0)
version-minor:
@echo "Incrementing minor version..."
@./scripts/release.sh minor --dry-run
## version-major: Increment major version (1.2.3 -> 2.0.0)
version-major:
@echo "Incrementing major version..."
@./scripts/release.sh major --dry-run