-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
91 lines (65 loc) · 2.13 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
GO_TAGS=
GO_ARGS=-tags '$(GO_TAGS)'
VERSION := $(shell git describe --exact-match --tags 2>/dev/null)
COMMIT := $(shell git rev-parse --short HEAD)
LDFLAGS := $(LDFLAGS) -X main.commit=$(COMMIT)
ifdef VERSION
LDFLAGS += -X main.version=$(VERSION)
endif
export GOBIN=$(shell go env GOPATH)/bin
export XC_ARCH=386 amd64 arm arm64
export XC_OS=solaris darwin freebsd linux windows
export CGO_ENABLED=0
export GO_BUILD=env GO111MODULE=on go build $(GO_ARGS) -ldflags "$(LDFLAGS)"
export GOX_BUILD=env GO111MODULE=on go run github.com/mitchellh/gox -os="$(XC_OS)" -arch="$(XC_ARCH)" -osarch="!darwin/arm !darwin/arm64 !darwin/386" \
-output "bin/dist/{{.OS}}_{{.Arch}}/{{.Dir}}" \
$(GO_ARGS) -ldflags "$(LDFLAGS)"
export GO_TEST=env GOTRACEBACK=all GO111MODULE=on go test $(GO_ARGS)
export GO_TEST_IT=env GOTRACEBACK=all GO111MODULE=on go test -count=1 -tags=integration -v
export GO_VET=env GO111MODULE=on go vet $(GO_ARGS)
export PATH := $(PWD)/bin/:$(PATH)
# All go source files
GO_SOURCES := $(shell find . -name '*.go')
SOURCES := $(GO_SOURCES) go.mod go.sum
# List of binary cmds to build
CMDS := \
bin/hpcwaas-api \
bin/waas
all: fmt $(CMDS)
#
# Define targets for commands
#
$(CMDS): fmt $(SOURCES)
$(GO_BUILD) -o $@ ./cmd/$(shell basename "$@")
# Ease of use build for just the go binary
hpcwaas-api: bin/hpcwaas-api
waas: bin/waas
dist: tools fmt
git config --global --add safe.directory /github/workspace
$(GOX_BUILD) ./cmd/waas
./scripts/dist.sh
tools:
env GO111MODULE=on go get -tags tools
fmt: generate
@gofmt -w -s $(GO_SOURCES)
tidy:
GO111MODULE=on go mod tidy
test-go:
$(GO_TEST) ./...
test: test-go
test-go-race:
CGO_ENABLED=1 $(GO_TEST) -v -race -count=1 ./...
test-json:
./bin/gotestsum --jsonfile tests-reports.json -- -tags "$(BUILD_TAGS)" $(TESTARGS) -count=1 -p 1 ./...
vet:
$(GO_VET) -v ./...
bench:
$(GO_TEST) -bench=. -run=^$$ ./...
build: all
clean:
$(RM) -r bin
generate: tools
# @go install github.com/abice/go-enum
@go generate ./...
# .PHONY targets represent actions that do not create an actual file.
.PHONY: all fmt tidy generate test test-go test-go-race bench clean vet