forked from cvakiitho/cloud-mta-build-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (58 loc) · 2.14 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
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
# Make build for local usage
# The artifact is bin for each OS and copied to the go/bin dir
# Execute go generate to generate files to *.go to inclue as binary
# Execute go build
# Copy files to machine go/bin folder (temp target to avoid manual steps when developing locally)
all:format clean dir gen build-linux build-linux-arm build-darwin build-darwin-arm build-windows copy tests
.PHONY: build-darwin-arm build-darwin build-linux build-linux-arm build-windows tests
GOCMD=go
GOBUILD=$(GOCMD) build
GOLANGCI_VERSION = 1.21.0
# Binary names
BINARY_NAME=mbt
BUILD = $(CURDIR)/release
format :
go fmt ./...
tools:
@echo "download golangci-lint"
curl -sLO https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_VERSION}/golangci-lint-${GOLANGCI_VERSION}-linux-amd64.tar.gz
tar -xzvf golangci-lint-${GOLANGCI_VERSION}-linux-amd64.tar.gz
cp golangci-lint-${GOLANGCI_VERSION}-linux-amd64/golangci-lint $(GOPATH)/bin
@echo "done"
lint:
@echo "Start project linting"
golangci-lint run --config .golangci.yml
@echo "done linting"
# execute general tests
tests:
go test -v -count=1 -timeout 30m ./...
# check code coverage
cover:
go test -v -coverprofile cover.out ./...
go tool cover -html=cover.out -o cover.html
open cover.html
clean:
rm -rf $(BUILD)
dir:
mkdir $(BUILD)
gen:
go generate
# build for each platform
build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o release/$(BINARY_NAME)_linux -v
build-linux-arm:
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(GOBUILD) -o release/$(BINARY_NAME)_linux_arm -v
build-darwin:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GOBUILD) -o release/$(BINARY_NAME) -v
build-darwin-arm:
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 $(GOBUILD) -o release/$(BINARY_NAME)_darwin_arm -v
build-windows:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) -o release/$(BINARY_NAME)_windows -v
# use for local development - > copy the new bin to go/bin path to use new compiled version
copy:
ifeq ($(OS),Windows_NT)
cp $(CURDIR)/release/$(BINARY_NAME)_windows $(GOPATH)/bin/$(BINARY_NAME).exe
else
cp $(CURDIR)/release/$(BINARY_NAME) $(GOPATH)/bin/
cp $(CURDIR)/release/$(BINARY_NAME) $~/usr/local/bin/
endif