-
Notifications
You must be signed in to change notification settings - Fork 30
/
common.mk
69 lines (60 loc) · 2.25 KB
/
common.mk
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
VERSION=$(shell git describe --tags --always)
.PHONY: init
# init env
init: init-api-tools
go install github.com/google/wire/cmd/wire@latest
go install github.com/vektra/mockery/v2@v2.43.2
# using binary release for atlas, since ent schema handler is not included
# in the community version anymore https://github.com/ariga/atlas/issues/2388#issuecomment-1864287189
curl -sSf https://atlasgo.sh | ATLAS_VERSION=v0.27.0 sh -s -- -y
# initialize API tooling
.PHONY: init-api-tools
init-api-tools:
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31.0
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0
go install github.com/bufbuild/buf/cmd/buf@v1.40.1
go install github.com/envoyproxy/protoc-gen-validate@v1.0.1
# Tools fixed to a specific version via its commit since they are not released standalone
go install github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2@v2.0.0-20231102162905-3fc8fb7a0a0b
go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@v2.0.0-20231102162905-3fc8fb7a0a0b
# 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: check-atlas-tool
check-atlas-tool:
@if ! command -v atlas >/dev/null 2>&1; then \
echo "altas is not installed. Please run \"make init\" or install the tool manually."; \
exit 1; \
fi
.PHONY: check-wire-tool
check-wire-tool:
@if ! command -v wire >/dev/null 2>&1; then \
echo "wire is not installed. Please run \"make init\" or install the tool manually."; \
exit 1; \
fi
.PHONY: check-golangci-lint-tool
check-golangci-lint-tool:
@if ! command -v golangci-lint >/dev/null 2>&1; then \
echo "golangci-lint is not installed. Please run \"make init\" or install the tool manually."; \
exit 1; \
fi
.PHONY: check-buf-tool
check-buf-tool:
@if ! command -v buf >/dev/null 2>&1; then \
echo "buf is not installed. Please run \"make init\" or install the tool manually."; \
exit 1; \
fi