|
1 | | -PROTOC=protoc \ |
| 1 | +GENERATED_DIR:="${CURDIR}/../generated/" |
| 2 | +THIRD_PARTY_DIR:="${CURDIR}/../third-party/" |
| 3 | + |
| 4 | +PROTOC:=protoc \ |
2 | 5 | -I ../proto/ \ |
3 | 6 | -I ../proto/wechaty/ \ |
| 7 | + -I ${THIRD_PARTY_DIR} \ |
4 | 8 | ../proto/wechaty/puppet.proto \ |
5 | 9 |
|
6 | 10 | .PHONY: all |
7 | | -all: clean generate reverse_proxy_server |
| 11 | +all: generate |
| 12 | + |
| 13 | +.PHONY: generate |
| 14 | +generate: |
| 15 | + ${PROTOC} \ |
| 16 | + --openapiv2_out ${GENERATED_DIR} \ |
| 17 | + --openapiv2_opt logtostderr=true \ |
| 18 | + --openapiv2_opt generate_unbound_methods=true \ |
8 | 19 |
|
9 | 20 | .PHONY: clean |
10 | 21 | clean: |
11 | | - rm -fr gen/* |
| 22 | + rm -fr ${GENERATED_DIR}/* |
12 | 23 |
|
13 | 24 | .PHONY: install |
14 | 25 | install: |
15 | | - [ -d gen ] || mkdir gen |
16 | 26 | go install \ |
17 | 27 | github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \ |
18 | 28 | github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \ |
19 | 29 | google.golang.org/protobuf/cmd/protoc-gen-go \ |
20 | 30 | google.golang.org/grpc/cmd/protoc-gen-go-grpc |
21 | 31 | go mod tidy |
22 | 32 |
|
23 | | -.PHONY: generate |
24 | | -generate: gen_protobuf gen_gateway gen_openapi |
25 | | - |
26 | 33 | .PHONY: gen_protobuf |
27 | 34 | gen_protobuf: |
28 | 35 | ${PROTOC} \ |
29 | | - --go_out ./gen/ --go_opt paths=source_relative \ |
30 | | - --go-grpc_out ./gen/ --go-grpc_opt paths=source_relative \ |
31 | | - ../proto/wechaty/puppet.proto |
| 36 | + --go_out ${GENERATED_DIR} --go_opt paths=source_relative \ |
| 37 | + --go-grpc_out ${GENERATED_DIR} --go-grpc_opt paths=source_relative \ |
32 | 38 |
|
33 | 39 | .PHONY: gen_gateway |
34 | 40 | gen_gateway: |
35 | 41 | ${PROTOC} \ |
36 | | - --grpc-gateway_out ./gen/ \ |
| 42 | + --grpc-gateway_out ${GENERATED_DIR} \ |
37 | 43 | --grpc-gateway_opt logtostderr=true \ |
38 | 44 | --grpc-gateway_opt paths=source_relative \ |
39 | 45 | --grpc-gateway_opt generate_unbound_methods=true \ |
40 | | - |
41 | | -.PHONY: gen_openapi |
42 | | -gen_openapi: |
43 | | - ${PROTOC} \ |
44 | | - --openapiv2_out ./gen/ \ |
45 | | - --openapiv2_opt logtostderr=true \ |
46 | | - |
0 commit comments