-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
74 lines (63 loc) · 2.39 KB
/
Makefile
File metadata and controls
74 lines (63 loc) · 2.39 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
# GABS Build Configuration
# This Makefile demonstrates how to build GABS with version information
# Version information
# Use the declared source version for local builds so rebuilt workspace binaries
# keep the release semantic version instead of inheriting a git "-dirty" suffix.
SOURCE_VERSION ?= $(shell sed -n 's/^[[:space:]]*Version = "\([^"]*\)".*/\1/p' internal/version/version.go | head -n 1)
VERSION ?= $(if $(SOURCE_VERSION),$(SOURCE_VERSION),dev)
COMMIT ?= $(shell git rev-parse HEAD 2>/dev/null || echo "unknown")
BUILD_DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
# Build flags
LDFLAGS = -ldflags "\
-X github.com/pardeike/gabs/internal/version.Version=$(VERSION) \
-X github.com/pardeike/gabs/internal/version.Commit=$(COMMIT) \
-X github.com/pardeike/gabs/internal/version.BuildDate=$(BUILD_DATE)"
# Default target
.PHONY: all
all: build
# Build the binary
.PHONY: build
build:
go build $(LDFLAGS) -o gabs ./cmd/gabs
# Build with debug information
.PHONY: build-debug
build-debug:
go build -gcflags="all=-N -l" $(LDFLAGS) -o gabs ./cmd/gabs
# Run tests
.PHONY: test
test:
go test -v ./...
# Clean build artifacts
.PHONY: clean
clean:
rm -f gabs gabs-test
# Install the binary
.PHONY: install
install:
go install $(LDFLAGS) ./cmd/gabs
# Show version information that would be embedded
.PHONY: version-info
version-info:
@echo "Source Version: $(SOURCE_VERSION)"
@echo "Version: $(VERSION)"
@echo "Commit: $(COMMIT)"
@echo "Build Date: $(BUILD_DATE)"
# Build for multiple platforms (example)
.PHONY: build-all
build-all:
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o gabs-linux-amd64 ./cmd/gabs
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o gabs-linux-arm64 ./cmd/gabs
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o gabs-darwin-amd64 ./cmd/gabs
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o gabs-darwin-arm64 ./cmd/gabs
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o gabs-windows-amd64.exe ./cmd/gabs
.PHONY: help
help:
@echo "Available targets:"
@echo " build - Build the GABS binary with version information"
@echo " build-debug - Build with debug symbols"
@echo " test - Run all tests"
@echo " clean - Remove build artifacts"
@echo " install - Install the binary"
@echo " version-info - Show version information that would be embedded"
@echo " build-all - Build Windows, macOS, and Linux binaries"
@echo " help - Show this help message"