-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
61 lines (50 loc) · 1.43 KB
/
Makefile
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
# Default target
.PHONY: all
all: build
MODULE_PATH := github.com/pmarchini/giogo
# Output directory for binaries
BIN_DIR := bin
# List of supported Linux architectures
ARCHS := \
amd64 \
arm64 \
arm \
386
# Feature toggles file
FT_FILE := .feature.toggles
# Read feature toggles from file and create -ldflags string
FT_FLAGS := $(shell if [ -f $(FT_FILE) ]; then \
awk -F '=' '{print "-X $(MODULE_PATH)/ft." $$1 "=" $$2}' $(FT_FILE) | paste -sd " "; \
fi)
# Build for the local architecture
.PHONY: build
build:
@echo "Building giogo for local Linux architecture with feature toggles"
go build -ldflags "$(FT_FLAGS)" -o giogo ./cmd/giogo
# Clean build artifacts
.PHONY: clean
clean:
@echo "Cleaning build artifacts"
rm -rf $(BIN_DIR)
rm -f giogo
# Build for all supported Linux architectures
.PHONY: build-all
build-all: clean
@echo "Building giogo for all Linux architectures with feature toggles"
@mkdir -p $(BIN_DIR)
@for arch in $(ARCHS); do \
output=$(BIN_DIR)/giogo-linux-$$arch; \
echo "Building $$output"; \
GOOS=linux GOARCH=$$arch go build -ldflags "$(FT_FLAGS)" -o $$output ./cmd/giogo; \
done
# Build for a specific Linux architecture
.PHONY: build-%
build-%:
@arch=$*; \
output=$(BIN_DIR)/giogo-linux-$$arch; \
echo "Building $$output"; \
GOOS=linux GOARCH=$$arch go build -ldflags "$(FT_FLAGS)" -o $$output ./cmd/giogo
.PHONY: test
test:
@echo "Running all tests with coverage"
go test -cover ./...