-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
43 lines (34 loc) · 824 Bytes
/
Copy pathMakefile
File metadata and controls
43 lines (34 loc) · 824 Bytes
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
BIN := openfriend
PKG := ./cmd/openfriend
DIST := dist
VERSION ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo dev)
LDFLAGS := -s -w -X main.version=$(VERSION)
PLATFORMS := \
darwin/amd64 \
darwin/arm64 \
linux/amd64 \
linux/arm64 \
windows/amd64
.PHONY: build clean dist test fmt vet tidy
build:
go build -ldflags '$(LDFLAGS)' -o $(BIN) $(PKG)
test:
go test ./...
fmt:
gofmt -w .
vet:
go vet ./...
tidy:
go mod tidy
clean:
rm -rf $(BIN) $(DIST)
dist: clean
@mkdir -p $(DIST)
@$(foreach p,$(PLATFORMS), \
os=$(word 1,$(subst /, ,$(p))); \
arch=$(word 2,$(subst /, ,$(p))); \
out=$(DIST)/$(BIN)-$$os-$$arch$$( [ "$$os" = "windows" ] && echo .exe ); \
echo "Building $$out..."; \
GOOS=$$os GOARCH=$$arch go build -ldflags '$(LDFLAGS)' -o $$out $(PKG) || exit 1; \
)
@ls -la $(DIST)