-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
98 lines (86 loc) · 2.62 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
92
93
94
95
96
97
98
GOPATH:=$(shell go env GOPATH)
VERSION=$(shell git describe --tags --always)
INTERNAL_PROTO_FILES=$(shell find internal -name *.proto)
API_PROTO_FILES := api/subscribe/v1/subscribe.proto
DOCKERTAG?=tkeelio/core-broker:0.4.1-alpha.3
LOCAL_OS := $(shell uname)
ifeq ($(LOCAL_OS),Linux)
TARGET_OS_LOCAL = linux
GOLANGCI_LINT:=golangci-lint
export ARCHIVE_EXT = .tar.gz
else ifeq ($(LOCAL_OS),Darwin)
TARGET_OS_LOCAL = darwin
GOLANGCI_LINT:=golangci-lint
export ARCHIVE_EXT = .tar.gz
else
TARGET_OS_LOCAL ?= windows
BINARY_EXT_LOCAL = .exe
GOLANGCI_LINT:=golangci-lint.exe
export ARCHIVE_EXT = .zip
endif
.PHONY: init
# init env
init:
go get -d -u github.com/tkeel-io/tkeel-interface/openapi
go get -d -u github.com/tkeel-io/kit
go get -d -u github.com/grpc-ecosystem/grpc-gateway/v2/[email protected]
go install github.com/tkeel-io/tkeel-interface/tool/cmd/artisan@latest
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
go install github.com/tkeel-io/tkeel-interface/protoc-gen-go-http@latest
go install github.com/tkeel-io/tkeel-interface/protoc-gen-go-errors@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/[email protected]
.PHONY: api
# generate api proto
api:
protoc --proto_path=. \
--proto_path=./third_party \
--go_out=paths=source_relative:. \
--go-http_out=paths=source_relative:. \
--go-grpc_out=paths=source_relative:. \
--go-errors_out=paths=source_relative:. \
--openapiv2_out=./api/ \
--openapiv2_opt=allow_merge=true \
--openapiv2_opt=logtostderr=true \
--openapiv2_opt=json_names_for_fields=false \
$(API_PROTO_FILES)
.PHONY: build
# build
build:
mkdir -p bin/ && CGO_ENABLED=0 go build -ldflags "-X main.Version=$(VERSION)" -o ./bin/ ./...
.PHONY: generate
# generate
generate:
go generate ./...
docker-build:
docker build -t $(DOCKERTAG) .
docker-push:
docker push $(DOCKERTAG)
docker-auto:
docker build -t $(DOCKERTAG) .
docker push $(DOCKERTAG)
.PHONY: all
# generate all
all:
make api;
make generate;
# show help
help:
@echo ''
@echo 'Usage:'
@echo ' make [target]'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^# (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \
printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
.DEFAULT_GOAL := help
.PHONY: lint
lint:
$(GOLANGCI_LINT) run --timeout=20m