-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
94 lines (76 loc) · 3.03 KB
/
Copy pathMakefile
File metadata and controls
94 lines (76 loc) · 3.03 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
.PHONY: help build build-go build-all clean test check image generate webui webui-deps webui-clean
# Build variables
BINARY_NAME := wonder
BUILD_DIR := bin
GO := go
GOFLAGS := -v
# Web UI variables
WEBUI_DIR := webui
WEBUI_DIST := $(WEBUI_DIR)/dist
WEBUI_STATIC := internal/app/coordinator/webui/static
# Version info: tag if tagged, "untagged" otherwise; sha with -dirty suffix if dirty
GIT_SHA := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
GIT_DIRTY := $(shell git diff-index --quiet HEAD -- 2>/dev/null || echo "dirty")
GIT_TAG := $(shell git describe --tags --exact-match 2>/dev/null)
ifdef GIT_TAG
VERSION := $(GIT_TAG)
else
VERSION := untagged
endif
ifdef GIT_DIRTY
GIT_SHA := $(GIT_SHA)-dirty
endif
VERSION_PKG := github.com/strrl/wonder-mesh-net/cmd/wonder/commands
LDFLAGS := -s -w -X $(VERSION_PKG).version=$(VERSION) -X $(VERSION_PKG).gitSHA=$(GIT_SHA)
help: ## Show this help message
@echo "Wonder Mesh Net - Build System"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_-]+:.*##/ { printf " %-15s %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
webui-deps: ## Install web UI dependencies
cd $(WEBUI_DIR) && npm ci
webui: webui-deps ## Build web UI
cd $(WEBUI_DIR) && npm run build
rm -rf $(WEBUI_STATIC)/assets
cp -r $(WEBUI_DIST)/* $(WEBUI_STATIC)/
webui-clean: ## Clean web UI build artifacts
rm -rf $(WEBUI_DIR)/node_modules $(WEBUI_DIST) $(WEBUI_STATIC)/assets
build-go: ## Build Go binary only (uses existing/placeholder UI)
@mkdir -p $(BUILD_DIR)
$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/wonder
build: webui build-go ## Build the wonder binary (includes web UI)
build-all: ## Build for all platforms (linux/darwin, amd64/arm64)
@mkdir -p $(BUILD_DIR)
GOOS=linux GOARCH=amd64 $(GO) build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 ./cmd/wonder
GOOS=linux GOARCH=arm64 $(GO) build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 ./cmd/wonder
GOOS=darwin GOARCH=amd64 $(GO) build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 ./cmd/wonder
GOOS=darwin GOARCH=arm64 $(GO) build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 ./cmd/wonder
clean: webui-clean ## Remove build artifacts
rm -rf $(BUILD_DIR)
rm -f coverage.out
test: ## Run tests
$(GO) test -race -coverprofile=coverage.out ./...
check: ## Run all code checks (fmt, vet, lint)
@echo "Running gofmt..."
@gofmt -w .
@echo "Running go vet..."
$(GO) vet ./...
@echo "Running golangci-lint..."
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run ./...; \
else \
echo "golangci-lint not installed, skipping"; \
fi
@echo "All checks passed"
image: ## Build and push multi-arch Docker image
./hack/build-image.sh
generate: ## Generate code (sqlc)
@echo "Running sqlc generate..."
@if command -v sqlc >/dev/null 2>&1; then \
sqlc generate; \
else \
echo "sqlc not installed. Install with: go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest"; \
exit 1; \
fi