-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
87 lines (71 loc) · 2.57 KB
/
Makefile
File metadata and controls
87 lines (71 loc) · 2.57 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
.PHONY: build run test clean install lint fmt vet check fix help
# Build variables
BINARY_NAME=opencode-sync
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT?=$(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
DATE?=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS=-ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)"
# Go commands
GOCMD=go
GOBUILD=$(GOCMD) build
GORUN=$(GOCMD) run
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
GOFMT=gofmt
## help: Show this help message
help:
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@sed -n 's/^##//p' $(MAKEFILE_LIST) | column -t -s ':' | sed -e 's/^/ /'
## build: Build the binary
build:
$(GOBUILD) $(LDFLAGS) -o $(BINARY_NAME) ./cmd/opencode-sync
## run: Run the application
run:
$(GORUN) $(LDFLAGS) ./cmd/opencode-sync
## test: Run tests
test:
$(GOTEST) -v ./...
## test-coverage: Run tests with coverage
test-coverage:
$(GOTEST) -v -coverprofile=coverage.out ./...
$(GOCMD) tool cover -html=coverage.out -o coverage.html
## clean: Clean build artifacts
clean:
rm -f $(BINARY_NAME)
rm -f coverage.out coverage.html
rm -rf dist/
## install: Install the binary to $GOPATH/bin
install:
$(GOBUILD) $(LDFLAGS) -o $(GOPATH)/bin/$(BINARY_NAME) ./cmd/opencode-sync
## deps: Download dependencies
deps:
$(GOMOD) download
$(GOMOD) tidy
## vet: Run go vet
vet:
$(GOCMD) vet ./...
## lint: Run linter
lint:
@which golangci-lint > /dev/null || (echo "Installing golangci-lint..." && go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest)
golangci-lint run --timeout=5m ./...
## fmt: Format code
fmt:
$(GOFMT) -s -w .
$(GOCMD) fmt ./...
## check: Run all checks (fmt, vet, lint)
check: fmt vet lint
@echo "All checks passed!"
## fix: Auto-fix linting issues where possible
fix:
@which golangci-lint > /dev/null || (echo "Installing golangci-lint..." && go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest)
golangci-lint run --fix --timeout=5m ./...
## build-all: Build for all platforms
build-all: clean
GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-amd64 ./cmd/opencode-sync
GOOS=linux GOARCH=arm64 $(GOBUILD) $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-arm64 ./cmd/opencode-sync
GOOS=darwin GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-amd64 ./cmd/opencode-sync
GOOS=darwin GOARCH=arm64 $(GOBUILD) $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-arm64 ./cmd/opencode-sync
GOOS=windows GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o dist/$(BINARY_NAME)-windows-amd64.exe ./cmd/opencode-sync