-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
279 lines (230 loc) · 9.98 KB
/
Makefile
File metadata and controls
279 lines (230 loc) · 9.98 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
# Makefile for numio - Natural Math Calculator
# ════════════════════════════════════════════════════════════════
# VARIABLES
# ════════════════════════════════════════════════════════════════
# Binary names
APP_NAME := numio
TUI_BIN := numio-tui
CLI_BIN := numio-cli
# Directories
CMD_DIR := ./cmd
BUILD_DIR := ./bin
TMP_DIR := ./tmp
# Go settings
GO := go
GOFLAGS := -v
LDFLAGS := -s -w
# Version (can be overridden: make build VERSION=1.0.0)
VERSION ?= 0.1.0
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_TIME := $(shell date -u '+%Y-%m-%d_%H:%M:%S')
# Linker flags with version info
LDFLAGS_VERSION := -X main.version=$(VERSION) -X main.commit=$(GIT_COMMIT) -X main.buildTime=$(BUILD_TIME)
# ════════════════════════════════════════════════════════════════
# DEFAULT TARGET
# ════════════════════════════════════════════════════════════════
.PHONY: all
all: build
# ════════════════════════════════════════════════════════════════
# DEVELOPMENT
# ════════════════════════════════════════════════════════════════
## dev: Run TUI with hot reload (requires air)
.PHONY: dev
dev:
@echo "Starting hot reload..."
@air -c .air.toml
## dev-cli: Run CLI with hot reload
.PHONY: dev-cli
dev-cli:
@air -c .air.cli.toml
## run: Run TUI directly (no hot reload)
.PHONY: run
run:
@$(GO) run $(CMD_DIR)/$(TUI_BIN)/main.go
## run-cli: Run CLI directly
.PHONY: run-cli
run-cli:
@$(GO) run $(CMD_DIR)/$(CLI_BIN)/main.go
## repl: Run CLI in REPL mode
.PHONY: repl
repl:
@$(GO) run $(CMD_DIR)/$(CLI_BIN)/main.go
# ════════════════════════════════════════════════════════════════
# BUILD
# ════════════════════════════════════════════════════════════════
## build: Build TUI, CLI, and desktop binaries
.PHONY: build
build: build-tui build-cli build-desktop
## build-tui: Build TUI binary
.PHONY: build-tui
build-tui:
@echo "Building $(TUI_BIN)..."
@mkdir -p $(BUILD_DIR)
@$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS) $(LDFLAGS_VERSION)" -o $(BUILD_DIR)/$(TUI_BIN) $(CMD_DIR)/$(TUI_BIN)
## build-cli: Build CLI binary
.PHONY: build-cli
build-cli:
@echo "Building $(CLI_BIN)..."
@mkdir -p $(BUILD_DIR)
@$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS) $(LDFLAGS_VERSION)" -o $(BUILD_DIR)/$(CLI_BIN) $(CMD_DIR)/$(CLI_BIN)
## build-desktop: Build desktop binary
.PHONY: build-desktop
build-desktop:
@echo "Building numio-desktop..."
@mkdir -p $(BUILD_DIR)
@$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS) $(LDFLAGS_VERSION)" -o $(BUILD_DIR)/numio-desktop $(CMD_DIR)/numio-desktop
## desktop: Run desktop app directly
.PHONY: desktop
desktop:
@$(GO) run $(CMD_DIR)/numio-desktop
## package-desktop: Package desktop app as macOS .app bundle
.PHONY: package-desktop
package-desktop:
@echo "Packaging Numio.app..."
@fyne package -os darwin -icon $(CURDIR)/Icon.png -name Numio --id com.numio.app --src ./cmd/numio-desktop
@echo "Done → Numio.app"
## build-release: Build optimized release binaries
.PHONY: build-release
build-release:
@echo "Building release binaries..."
@mkdir -p $(BUILD_DIR)
@CGO_ENABLED=0 $(GO) build -ldflags "$(LDFLAGS) $(LDFLAGS_VERSION)" -o $(BUILD_DIR)/$(TUI_BIN) $(CMD_DIR)/$(TUI_BIN)
@CGO_ENABLED=0 $(GO) build -ldflags "$(LDFLAGS) $(LDFLAGS_VERSION)" -o $(BUILD_DIR)/$(CLI_BIN) $(CMD_DIR)/$(CLI_BIN)
# ════════════════════════════════════════════════════════════════
# INSTALL
# ════════════════════════════════════════════════════════════════
## install: Install binaries to GOPATH/bin
.PHONY: install
install:
@echo "Installing $(TUI_BIN) and $(CLI_BIN)..."
@$(GO) install $(CMD_DIR)/$(TUI_BIN)
@$(GO) install $(CMD_DIR)/$(CLI_BIN)
## uninstall: Remove installed binaries
.PHONY: uninstall
uninstall:
@echo "Uninstalling..."
@rm -f $(shell go env GOPATH)/bin/$(TUI_BIN)
@rm -f $(shell go env GOPATH)/bin/$(CLI_BIN)
# ════════════════════════════════════════════════════════════════
# TEST
# ════════════════════════════════════════════════════════════════
## test: Run all tests
.PHONY: test
test:
@echo "Running tests..."
@$(GO) test ./... -v
## test-short: Run tests without verbose output
.PHONY: test-short
test-short:
@$(GO) test ./...
## test-cover: Run tests with coverage
.PHONY: test-cover
test-cover:
@echo "Running tests with coverage..."
@$(GO) test ./... -coverprofile=coverage.out
@$(GO) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
## test-race: Run tests with race detector
.PHONY: test-race
test-race:
@echo "Running tests with race detector..."
@$(GO) test ./... -race
## bench: Run benchmarks
.PHONY: bench
bench:
@echo "Running benchmarks..."
@$(GO) test ./... -bench=. -benchmem
# ════════════════════════════════════════════════════════════════
# LINT & FORMAT
# ════════════════════════════════════════════════════════════════
## fmt: Format code
.PHONY: fmt
fmt:
@echo "Formatting code..."
@$(GO) fmt ./...
## vet: Run go vet
.PHONY: vet
vet:
@echo "Running go vet..."
@$(GO) vet ./...
## lint: Run golangci-lint (requires golangci-lint)
.PHONY: lint
lint:
@echo "Running linter..."
@golangci-lint run ./...
## check: Run fmt, vet, and test
.PHONY: check
check: fmt vet test-short
# ════════════════════════════════════════════════════════════════
# DEPENDENCIES
# ════════════════════════════════════════════════════════════════
## deps: Download dependencies
.PHONY: deps
deps:
@echo "Downloading dependencies..."
@$(GO) mod download
## deps-update: Update dependencies
.PHONY: deps-update
deps-update:
@echo "Updating dependencies..."
@$(GO) get -u ./...
@$(GO) mod tidy
## deps-tidy: Tidy go.mod
.PHONY: deps-tidy
deps-tidy:
@echo "Tidying dependencies..."
@$(GO) mod tidy
## deps-verify: Verify dependencies
.PHONY: deps-verify
deps-verify:
@echo "Verifying dependencies..."
@$(GO) mod verify
# ════════════════════════════════════════════════════════════════
# TOOLS
# ════════════════════════════════════════════════════════════════
## tools: Install development tools
.PHONY: tools
tools:
@echo "Installing development tools..."
@go install github.com/air-verse/air@latest
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@go install fyne.io/tools/cmd/fyne@latest
@echo "Tools installed."
## tools-check: Check if required tools are installed
.PHONY: tools-check
tools-check:
@echo "Checking tools..."
@which air > /dev/null || (echo "air not found. Run: make tools" && exit 1)
@echo "✓ air"
@which golangci-lint > /dev/null || echo "⚠ golangci-lint not found (optional)"
@echo "All required tools installed."
# ════════════════════════════════════════════════════════════════
# CLEAN
# ════════════════════════════════════════════════════════════════
## clean: Remove build artifacts
.PHONY: clean
clean:
@echo "Cleaning..."
@rm -rf $(BUILD_DIR)
@rm -rf $(TMP_DIR)
@rm -f coverage.out coverage.html
@echo "Clean complete."
## clean-cache: Clean Go build cache
.PHONY: clean-cache
clean-cache:
@echo "Cleaning Go cache..."
@$(GO) clean -cache -testcache
# ════════════════════════════════════════════════════════════════
# HELP
# ════════════════════════════════════════════════════════════════
## help: Show this help message
.PHONY: help
help:
@echo ""
@echo "numio - Natural Math Calculator"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@grep -E '^## ' $(MAKEFILE_LIST) | sed -e 's/## / /' | column -t -s ':'
@echo ""