-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
43 lines (31 loc) · 1.12 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
# Define the output binary name
BINARY_NAME := tfc-collect
# Specify the platforms you want to support
PLATFORMS := windows darwin linux
# Define the architectures for each platform
ARCH_windows := amd64
ARCH_darwin := amd64
ARCH_linux := amd64 386
# Calculate the OS-ARCH pairs for cross-compilation
OS_ARCH_PAIRS := $(foreach platform, $(PLATFORMS), $(addprefix $(platform)/, $(ARCH_$(platform))))
# Output directory for the binary files
BIN_DIR := bin
# Default target: build for all specified platforms
all: $(OS_ARCH_PAIRS)
# Create a target for each platform-architecture pair
$(OS_ARCH_PAIRS):
GOOS=$(firstword $(subst /, ,$@)) GOARCH=$(lastword $(subst /, ,$@)) go build -buildvcs=false -o $(BIN_DIR)/$(BINARY_NAME)_$(firstword $(subst /, ,$@))_$(lastword $(subst /, ,$@))
# Clean up generated binaries
clean:
rm -rf $(BIN_DIR)
# Build for the current platform (useful for local development)
build:
go build -o $(BIN_DIR)/$(BINARY_NAME)
# Phony targets
.PHONY: all $(OS_ARCH_PAIRS) clean build
test:
go test ./... -coverprofile=./cov.out -covermode=atomic -coverpkg=./...
run:
go run main.go
lint:
golangci-lint run