-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
198 lines (163 loc) · 6.52 KB
/
Copy pathMakefile
File metadata and controls
198 lines (163 loc) · 6.52 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
.PHONY: help build install test clean fmt lint run dev doctor release
# Variables
BINARY_NAME=walgo
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_DATE=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
LDFLAGS=-ldflags "-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(BUILD_DATE)"
help: ## Show this help message
@echo "Walgo - Development Makefile"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-15s %s\n", $$1, $$2}'
build: ## Build the binary
@echo "Building $(BINARY_NAME)..."
@go build $(LDFLAGS) -o $(BINARY_NAME) main.go
@echo "✓ Built $(BINARY_NAME) ($(VERSION))"
install: build ## Build and install to /usr/local/bin
@echo "Installing $(BINARY_NAME) to /usr/local/bin..."
@sudo mv $(BINARY_NAME) /usr/local/bin/
@echo "✓ Installed $(BINARY_NAME)"
install-user: build ## Build and install to ~/.local/bin
@echo "Installing $(BINARY_NAME) to ~/.local/bin..."
@mkdir -p ~/.local/bin
@mv $(BINARY_NAME) ~/.local/bin/
@echo "✓ Installed $(BINARY_NAME) to ~/.local/bin"
@echo " Make sure ~/.local/bin is in your PATH"
test: ## Run tests
@echo "Running tests..."
@go test -v -race -coverprofile=coverage.out ./...
@echo "✓ Tests passed"
test-coverage: test ## Run tests and show coverage
@go tool cover -html=coverage.out
test-short: ## Run tests without race detector (faster)
@go test -short ./...
clean: ## Remove build artifacts
@echo "Cleaning..."
@rm -f $(BINARY_NAME)
@rm -f coverage.out coverage.txt
@rm -rf dist/
@echo "✓ Cleaned"
fmt: ## Format code
@echo "Formatting code..."
@go fmt ./...
@echo "✓ Formatted"
lint: ## Run linters
@echo "Running linters..."
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run; \
echo "✓ Linting passed"; \
else \
echo "⚠ golangci-lint not installed, running basic checks..."; \
go vet ./...; \
echo "✓ Basic checks passed"; \
fi
vet: ## Run go vet
@go vet ./...
tidy: ## Tidy dependencies
@echo "Tidying dependencies..."
@go mod tidy
@go mod verify
@echo "✓ Dependencies tidied"
run: build ## Build and run walgo
@./$(BINARY_NAME)
dev: ## Build and run doctor command
@go run main.go doctor
doctor: build ## Build and run full diagnostics
@./$(BINARY_NAME) doctor --verbose
# Release targets
release-dry: clean ## Dry run of release process
@echo "Running release dry-run..."
@goreleaser release --snapshot --clean --skip=publish
@echo "✓ Release dry-run complete"
release-snapshot: clean ## Build snapshot release locally
@goreleaser release --snapshot --clean
@echo "✓ Snapshot release created in dist/"
# Cross-compilation targets
build-all: clean ## Build for all platforms
@echo "Building for all platforms..."
@mkdir -p dist
@GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-amd64 main.go
@GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-arm64 main.go
@GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-amd64 main.go
@GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-arm64 main.go
@GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-windows-amd64.exe main.go
@echo "✓ Built binaries in dist/"
@ls -lh dist/
# Docker targets
docker-build: ## Build Docker image
@docker build -t $(BINARY_NAME):$(VERSION) .
@docker tag $(BINARY_NAME):$(VERSION) $(BINARY_NAME):latest
@echo "✓ Built Docker image $(BINARY_NAME):$(VERSION)"
docker-run: docker-build ## Build and run Docker image
@docker run --rm $(BINARY_NAME):latest
# Development helpers
watch: ## Watch for changes and rebuild (requires entr)
@if command -v entr >/dev/null 2>&1; then \
find . -name '*.go' | entr -c make build; \
else \
echo "⚠ entr not installed. Install with: brew install entr (macOS)"; \
fi
deps-install: ## Install development dependencies
@echo "Installing development dependencies..."
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@go install github.com/goreleaser/goreleaser@latest
@echo "✓ Installed development dependencies"
check: fmt vet test ## Run formatting, vetting, and tests
all: clean fmt vet test build ## Clean, format, test, and build
# Quick development workflow
quick: ## Quick build and test
@make -s build && make -s test-short
# Version info
version: ## Show version information
@echo "Version: $(VERSION)"
@echo "Commit: $(COMMIT)"
@echo "Date: $(BUILD_DATE)"
# Desktop App targets
desktop-dev: ## Run desktop app in development mode
@echo "Starting desktop app in development mode..."
@cd desktop && wails dev
desktop-build: ## Build desktop app for current platform
@echo "Building desktop app for current platform..."
@cd desktop && wails build
@echo "✓ Desktop app built in desktop/build/bin/"
desktop-build-darwin: ## Build desktop app for macOS (both architectures)
@echo "Building desktop app for macOS..."
@cd desktop && wails build -platform darwin/universal
@echo "✓ macOS universal binary built in desktop/build/bin/"
desktop-build-windows: ## Build desktop app for Windows
@echo "Building desktop app for Windows..."
@cd desktop && wails build -platform windows/amd64
@echo "✓ Windows build completed in desktop/build/bin/"
desktop-build-linux: ## Build desktop app for Linux
@echo "Building desktop app for Linux..."
@cd desktop && wails build -platform linux/amd64
@echo "✓ Linux build completed in desktop/build/bin/"
desktop-build-all: ## Build desktop app for all platforms
@echo "Building desktop app for all platforms..."
@echo ""
@echo "=== Building for macOS (Universal) ==="
@cd desktop && wails build -platform darwin/universal -clean
@echo ""
@echo "=== Building for Windows (amd64) ==="
@cd desktop && wails build -platform windows/amd64 -clean
@echo ""
@echo "=== Building for Linux (amd64) ==="
@cd desktop && wails build -platform linux/amd64 -clean
@echo ""
@echo "✓ All desktop builds completed!"
@echo ""
@echo "Build artifacts:"
@ls -lh desktop/build/bin/
desktop-clean: ## Clean desktop build artifacts
@echo "Cleaning desktop build artifacts..."
@rm -rf desktop/build/bin/
@rm -rf desktop/frontend/dist/
@rm -rf desktop/frontend/node_modules/.vite/
@echo "✓ Desktop build artifacts cleaned"
desktop-install-deps: ## Install desktop frontend dependencies
@echo "Installing desktop frontend dependencies..."
@cd desktop/frontend && npm install
@echo "✓ Frontend dependencies installed"