|
| 1 | +.PHONY: all build build-frontend build-go clean dev install test lint help |
| 2 | + |
| 3 | +# Version info |
| 4 | +VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev") |
| 5 | +COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown") |
| 6 | +DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") |
| 7 | + |
| 8 | +# Build flags |
| 9 | +LDFLAGS := -s -w \ |
| 10 | + -X main.version=$(VERSION) \ |
| 11 | + -X main.commit=$(COMMIT) \ |
| 12 | + -X main.buildDate=$(DATE) |
| 13 | + |
| 14 | +# Default target |
| 15 | +all: build |
| 16 | + |
| 17 | +# Build everything (frontend + Go binary) |
| 18 | +build: build-frontend build-go |
| 19 | + |
| 20 | +# Build frontend assets |
| 21 | +build-frontend: |
| 22 | + @echo "Building frontend..." |
| 23 | + cd web && pnpm install && pnpm run build |
| 24 | + |
| 25 | +# Build Go binary (requires frontend to be built first) |
| 26 | +build-go: |
| 27 | + @echo "Building Go binary..." |
| 28 | + go build -ldflags "$(LDFLAGS)" -o devrouter ./cmd/devrouter |
| 29 | + |
| 30 | +# Install binary to $GOPATH/bin |
| 31 | +install: build |
| 32 | + @echo "Installing devrouter..." |
| 33 | + go install -ldflags "$(LDFLAGS)" ./cmd/devrouter |
| 34 | + |
| 35 | +# Clean build artifacts |
| 36 | +clean: |
| 37 | + @echo "Cleaning..." |
| 38 | + rm -f devrouter |
| 39 | + rm -rf internal/devrouter/web/dist/assets |
| 40 | + rm -f internal/devrouter/web/dist/index.html |
| 41 | + |
| 42 | +# Run frontend dev server |
| 43 | +dev: |
| 44 | + cd web && pnpm run dev |
| 45 | + |
| 46 | +# Run tests |
| 47 | +test: |
| 48 | + go test ./... |
| 49 | + cd web && pnpm run test |
| 50 | + |
| 51 | +# Run linters |
| 52 | +lint: |
| 53 | + go vet ./... |
| 54 | + cd web && pnpm run check |
| 55 | + |
| 56 | +# Help |
| 57 | +help: |
| 58 | + @echo "Available targets:" |
| 59 | + @echo " make build - Build frontend and Go binary" |
| 60 | + @echo " make build-frontend - Build frontend only" |
| 61 | + @echo " make build-go - Build Go binary only (requires frontend)" |
| 62 | + @echo " make install - Build and install to GOPATH/bin" |
| 63 | + @echo " make clean - Remove build artifacts" |
| 64 | + @echo " make dev - Run frontend dev server" |
| 65 | + @echo " make test - Run all tests" |
| 66 | + @echo " make lint - Run linters" |
0 commit comments