-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
46 lines (33 loc) · 1.21 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
all: fmt-check lint-check build
BINDIR := bin
LINTER_VERSION := 1.45.2
LINTER := $(BINDIR)/golangci-lint_$(LINTER_VERSION)
DEV_OS := $(shell uname -s | tr A-Z a-z)
$(LINTER):
mkdir -p $(BINDIR)
wget "https://github.com/golangci/golangci-lint/releases/download/v$(LINTER_VERSION)/golangci-lint-$(LINTER_VERSION)-$(DEV_OS)-amd64.tar.gz" -O - \
| tar -xz -C $(BINDIR) --strip-components=1 --exclude=README.md --exclude=LICENSE
mv $(BINDIR)/golangci-lint $(LINTER)
.PHONY: fmt-check
fmt-check:
BADFILES=$$(gofmt -l -s -d $$(find . -type f -name '*.go')) && [ -z "$$BADFILES" ] && exit 0
.PHONY: lint-check
lint-check: $(LINTER)
$(LINTER) run --deadline=2m
## DEBUG BUILDS
GO_FILES = $(shell find . -type f -name '*.go')
$(BINDIR)/gpublame: $(GO_FILES)
mkdir -p $(BINDIR)
go build -o $(BINDIR)/gpublame ./cmd
.PHONY: build
build: $(BINDIR)/gpublame
## RELEASE BUILDS
RELEASEDIR := $(BINDIR)/release
ARCHES := amd64 arm arm64
# This rule expects targets with the format $(RELEASEDIR)/gpublame-GOARCH
$(RELEASEDIR)/gpublame-%: $(GO_FILES)
mkdir -p $(RELEASEDIR)
GOARCH=$(word 2,$(subst -, ,$@)) \
go build -o $@ -ldflags "-s -w" ./cmd
.PHONY: release
release: $(foreach arch,$(ARCHES),$(RELEASEDIR)/gpublame-$(arch))