-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
90 lines (77 loc) · 1.97 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
SRC_MAKEFILES := $(foreach dir, app, $(wildcard $(dir)/*/*/Makefile))
.PHONY: init dep api conf ent wire openapi build clean run test
# init env
init:
go install entgo.io/ent/cmd/ent@latest
go install github.com/google/gnostic/cmd/protoc-gen-openapi@latest
go install github.com/google/wire/cmd/wire@latest
go install github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2@latest
go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@latest
cd api && buf mod update
# download dependencies of module
dep:
$(foreach dir, $(dir $(realpath $(SRC_MAKEFILES))),\
cd $(dir);\
make dep;\
)
# generate protobuf api go code
api:
cd $(lastword $(dir $(realpath $(SRC_MAKEFILES))));\
make api;
# generate config define code
conf:
$(foreach dir, $(dir $(realpath $(SRC_MAKEFILES))),\
cd $(dir);\
make conf;\
)
# generate ent code
ent:
$(foreach dir, $(dir $(realpath $(SRC_MAKEFILES))),\
cd $(dir);\
make ent;\
)
# generate wire code
wire:
$(foreach dir, $(dir $(realpath $(SRC_MAKEFILES))),\
cd $(dir);\
make wire;\
)
# generate OpenAPI v3 docs.
openapi:
cd $(lastword $(dir $(realpath $(SRC_MAKEFILES))));\
make openapi;
# build all service applications
build:
$(foreach dir, $(dir $(realpath $(SRC_MAKEFILES))),\
cd $(dir);\
make build;\
)
# clean build files
clean:
$(foreach dir, $(dir $(realpath $(SRC_MAKEFILES))),\
cd $(dir);\
make clean;\
)
# run tests
test:
$(foreach dir, $(dir $(realpath $(SRC_MAKEFILES))),\
cd $(dir);\
make test;\
)
# 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