-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
82 lines (67 loc) · 1.55 KB
/
Makefile
File metadata and controls
82 lines (67 loc) · 1.55 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
# TinyMuscle Makefile
# Minimal, explicit, no magic — Go style
BINARY_NAME := tinymuscle
CMD_PATH := ./cmd/main.go
BUILD_DIR := build
# Default target
.PHONY: all
all: build
## -------------------------
## Local Development
## -------------------------
.PHONY: build
build:
@echo "→ Building $(BINARY_NAME)"
@go build -o $(BINARY_NAME) $(CMD_PATH)
.PHONY: run
run: build
@echo "→ Running $(BINARY_NAME)"
@export $$(cat .env | xargs) && ./$(BINARY_NAME)
.PHONY: clean
clean:
@echo "→ Cleaning binaries"
@rm -f $(BINARY_NAME)
@rm -rf $(BUILD_DIR)
## -------------------------
## Cross Compilation
## -------------------------
PLATFORMS := \
linux/amd64 \
linux/arm64 \
darwin/amd64 \
darwin/arm64 \
windows/amd64
.PHONY: cross
cross:
@echo "→ Cross compiling..."
@mkdir -p $(BUILD_DIR)
@for platform in $(PLATFORMS); do \
GOOS=$${platform%/*}; \
GOARCH=$${platform#*/}; \
output_name=$(BINARY_NAME)-$$GOOS-$$GOARCH; \
if [ "$$GOOS" = "windows" ]; then output_name="$$output_name.exe"; fi; \
echo "→ $$output_name"; \
GOOS=$$GOOS GOARCH=$$GOARCH go build -o $(BUILD_DIR)/$$output_name $(CMD_PATH); \
done
## -------------------------
## Install (local system)
## -------------------------
.PHONY: install
install:
@echo "→ Installing $(BINARY_NAME) to GOPATH/bin"
@go install $(CMD_PATH)
## -------------------------
## Quality
## -------------------------
.PHONY: fmt
fmt:
@echo "→ Formatting"
@gofmt -s -w .
.PHONY: vet
vet:
@echo "→ Vetting"
@go vet ./...
.PHONY: tidy
tidy:
@echo "→ Tidying modules"
@go mod tidy