forked from SAP/cloud-mta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
68 lines (51 loc) · 1.68 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
all:format test clean dir gen build-linux build-darwin build-darwin-arm build-windows copy test
.PHONY: format test tools
GOCMD=go
GOBUILD=$(GOCMD) build
GOLANGCI_VERSION = 1.21.0
# Binary names
BINARY_NAME=mta
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
test:
go test -v -race ./...
# 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-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