-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathMakefile
More file actions
69 lines (55 loc) · 1.92 KB
/
Makefile
File metadata and controls
69 lines (55 loc) · 1.92 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
.PHONY: build run test clean install help sign
# Build variables
BINARY_NAME=lazypg
BUILD_DIR=bin
VERSION?=dev
LDFLAGS=-ldflags "-X main.version=${VERSION}"
UNAME_S := $(shell uname -s)
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
build: ## Build the binary (with code signing on macOS)
@echo "Building ${BINARY_NAME}..."
@mkdir -p ${BUILD_DIR}
@go build ${LDFLAGS} -o ${BUILD_DIR}/${BINARY_NAME} cmd/lazypg/main.go
ifeq ($(UNAME_S),Darwin)
@echo "Signing binary for macOS keychain compatibility..."
@codesign -s - -f ${BUILD_DIR}/${BINARY_NAME}
endif
@echo "Built ${BUILD_DIR}/${BINARY_NAME}"
sign: ## Sign the binary (macOS only, for keychain "Always Allow")
ifeq ($(UNAME_S),Darwin)
@codesign -s - -f ${BUILD_DIR}/${BINARY_NAME}
@echo "Signed ${BUILD_DIR}/${BINARY_NAME}"
else
@echo "Code signing is only needed on macOS"
endif
run: build ## Build and run the application
@${BUILD_DIR}/${BINARY_NAME}
test: ## Run tests
@go test -v -race -coverprofile=coverage.out ./...
test-coverage: test ## Run tests and show coverage
@go tool cover -html=coverage.out
clean: ## Remove build artifacts
@rm -rf ${BUILD_DIR}
@rm -f coverage.out
@echo "Cleaned build artifacts"
install: build ## Install binary to $GOPATH/bin (with code signing on macOS)
@go install ./cmd/lazypg
ifeq ($(UNAME_S),Darwin)
@codesign -s - -f $(shell go env GOPATH)/bin/${BINARY_NAME}
endif
@echo "Installed to $(shell go env GOPATH)/bin/${BINARY_NAME}"
fmt: ## Format code
@go fmt ./...
lint: ## Run linter
@golangci-lint run ./... || echo "golangci-lint not installed, skipping"
deps: ## Download dependencies
@go mod download
@go mod tidy
dev: ## Run in development mode with hot reload
@echo "Running in development mode (press Ctrl+C to stop)..."
@go run cmd/lazypg/main.go
.DEFAULT_GOAL := help