forked from nightshift2k/binance-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (63 loc) · 1.87 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
PROJECT := binance-proxy
VERSION := $(shell git describe --abbrev=0 --tags)
COMMIT_HASH := $(shell git rev-parse --short HEAD)
GOLDFLAGS_VERSION := $(VERSION)-$(COMMIT_HASH)
GOLDFLAGS_BUILD_TIME := $(shell date -Is)
LD_FLAGS := -X main.Version='$(GOLDFLAGS_VERSION)' -X main.Buildtime='$(GOLDFLAGS_BUILD_TIME)' -s -w
SOURCE_FILES ?= ./internal/... ./pkg/... ./cmd/...
UNAME := $(uname -s)
$(info GOLDFLAGS_VERSION=$(GOLDFLAGS_VERSION))
$(info GOLDFLAGS_BUILD_TIME=$(GOLDFLAGS_BUILD_TIME))
$(info LD_FLAGS=$(LD_FLAGS))
export CGO_ENABLED=0
export GO111MODULE=on
.PHONY: all
all: help
.PHONY: help
help: ### Show targets documentation
ifeq ($(UNAME), Linux)
@grep -P '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
else
@awk -F ':.*###' '$$0 ~ FS {printf "%15s%s\n", $$1 ":", $$2}' \
$(MAKEFILE_LIST) | grep -v '@awk' | sort
endif
.PHONY: clean
clean: ### Clean build files
@rm -rf ./bin
@go clean
.PHONY: build
build: clean ### Build binary
@go build -tags netgo -a -v -ldflags "${LD_FLAGS}" -o ./bin/binance-proxy ./cmd/binance-proxy/*.go
@chmod +x ./bin/*
.PHONY: run
run: ### Quick run
@CGO_ENABLED=1 go run -race cmd/binance-proxy/*.go
.PHONY: deps
deps: ### Optimize dependencies
@go mod tidy
.PHONY: vendor
vendor: ### Vendor dependencies
@go mod vendor
.PHONY: install
install: ### Install binary in your system
@go install -v cmd/binance-proxy/*.go
.PHONY: fmt
fmt: ### Format
@gofmt -s -w .
.PHONY: vet
vet: ### Vet
@go vet ./...
### Lint
.PHONY: lint
lint: fmt vet
### Clean test
.PHONY: test-clean
test-clean: ### Clean test cache
@go clean -testcache ./...
.PHONY: test
test: lint ### Run tests
@go test -v -coverprofile=cover.out -timeout 10s ./...
.PHONY: cover
cover: test ### Run tests and generate coverage
@go tool cover -html=cover.out -o=cover.html