-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
56 lines (48 loc) · 2.66 KB
/
Copy pathMakefile
File metadata and controls
56 lines (48 loc) · 2.66 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
.PHONY: build build-all build-debug clean run
BINARY_NAME=twitchpoint
BUILD_DIR=bin
# Release linker flags:
# -s strips the symbol table
# -w strips the DWARF debug-info table
# Combined they shave ~25-30% off the binary size with zero behavior
# change. Stack traces from panics still resolve to function names
# (Go embeds those separately) but won't show file:line numbers.
RELEASE_LDFLAGS=-s -w
# Map the host's GOOS/GOARCH to the same naming convention build-all
# uses, so `make build` overwrites the platform-suffixed binary the
# user actually launches (e.g. bin/twitchpoint-macos on Apple Silicon)
# instead of dropping a generic bin/twitchpoint that gets ignored.
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
PLATFORM_SUFFIX := $(strip \
$(if $(filter darwin/arm64,$(GOOS)/$(GOARCH)),-macos,\
$(if $(filter darwin/amd64,$(GOOS)/$(GOARCH)),-macos-intel,\
$(if $(filter linux/amd64,$(GOOS)/$(GOARCH)),-linux,\
$(if $(filter linux/arm64,$(GOOS)/$(GOARCH)),-linux-arm64,\
$(if $(filter windows/amd64,$(GOOS)/$(GOARCH)),-windows.exe,\
))))))
# `make build` — current platform, release-flavored (stripped, no debug tag).
build:
go build -ldflags="$(RELEASE_LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)$(PLATFORM_SUFFIX) ./cmd/twitchpoint
# `make build-debug` — current platform, with -tags=debug (UI shows
# every prober/heartbeat tick, file:line in stack traces). For
# diagnosing pick / credit issues; never used for releases.
build-debug:
go build -tags=debug -o $(BUILD_DIR)/$(BINARY_NAME)-debug ./cmd/twitchpoint
# `make build-all` — cross-compile every release target. ALL targets
# are stripped + tag-free. Naming kept stable for existing release URLs:
# twitchpoint-macos = darwin/arm64 (Apple Silicon — primary)
# twitchpoint-macos-intel = darwin/amd64 (Apple Intel)
# twitchpoint-linux = linux/amd64 (Intel/AMD x86_64)
# twitchpoint-linux-arm64 = linux/arm64 (Raspberry Pi, ARM servers)
# twitchpoint-windows.exe = windows/amd64
build-all:
GOOS=darwin GOARCH=arm64 go build -ldflags="$(RELEASE_LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-macos ./cmd/twitchpoint
GOOS=darwin GOARCH=amd64 go build -ldflags="$(RELEASE_LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-macos-intel ./cmd/twitchpoint
GOOS=linux GOARCH=amd64 go build -ldflags="$(RELEASE_LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-linux ./cmd/twitchpoint
GOOS=linux GOARCH=arm64 go build -ldflags="$(RELEASE_LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 ./cmd/twitchpoint
GOOS=windows GOARCH=amd64 go build -ldflags="$(RELEASE_LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-windows.exe ./cmd/twitchpoint
run:
go run ./cmd/twitchpoint
clean:
rm -rf $(BUILD_DIR)