-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
38 lines (28 loc) · 877 Bytes
/
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
app_name := bngblasterctrl
app_ver := $(shell git describe --abbrev=0 --tags)
LDFLAGS := -X 'main.Version=$(app_ver)' -s -w $(LDFLAGS)
OS := $(if $(GOOS),$(GOOS),$(shell go env GOOS))
ARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))
fumpt:
gofumpt -l -w .
test:
go test -v -cover ./...
lint:
golangci-lint run
gci:
gci write -s Standard -s Default -s "Prefix(github.com/rtbrick)" .
build-%:
@echo "[run] build-OS_ARCH"
@$(MAKE) build \
--no-print-directory \
GOOS=$(firstword $(subst _, ,$*)) \
GOARCH=$(lastword $(subst _, ,$*))
BUILD_DIR := bin/$(OS)_$(ARCH)
build:
@echo build $(OS)_$(ARCH) $(app_ver)
@mkdir -p $(BUILD_DIR)
env GOOS=$(OS) GOARCH=$(ARCH) go build -o $(BUILD_DIR)/$(app_name) -ldflags '$(LDFLAGS)' ./cmd/$(app_name)/
.PHONY: clean test
clean:
@echo "[run] clean"
@- rm -rf bin