-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
39 lines (34 loc) · 1.25 KB
/
Copy pathMakefile
File metadata and controls
39 lines (34 loc) · 1.25 KB
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
GROUP_NAME=gochat
PROJECT_NAME=gochat
API_ROOT=/api/v1
API_PROTO_FILES=$(shell find api -name *.proto)
API_PB_FILES=$(shell find api -name "*.pb.go")
grpc:
protoc --proto_path=./api \
--proto_path=./third_party \
--go_out=paths=source_relative:./api \
--go-grpc_out=paths=source_relative:./api \
--validate_out=paths=source_relative,lang=go:./api \
--openapiv2_out=./api \
--experimental_allow_proto3_optional \
$(API_PROTO_FILES)
$(MAKE) inject-tags
# 在pb.go文件中注入自定义tag
# go install github.com/favadi/protoc-go-inject-tag@latest
.PHONY: inject-tags
inject-tags:
$(foreach file, $(API_PB_FILES), protoc-go-inject-tag -input=$(file);)
# 安装必要的工具
install-tools:
go install github.com/favadi/protoc-go-inject-tag@latest
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
go install github.com/envoyproxy/protoc-gen-validate@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest
# 清理生成的文件
clean:
find api -name "*.pb.go" -delete
find api -name "*_grpc.pb.go" -delete
find api -name "*.pb.validate.go" -delete
find api -name "*.swagger.json" -delete
.PHONY: grpc inject-tags install-tools clean