forked from Badmoonz/api-schema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
99 lines (89 loc) · 3.17 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
99
.PHONY: java swagger gateway python2 python3 php golang
PROJECT_PATH := $(shell pwd)
PROTO_PATH := $(PROJECT_PATH)/proto
JAVA_GEN_PATH := $(PROJECT_PATH)/java
PHP_GEN_PATH := $(PROJECT_PATH)/php
SWAGGER_PATH := $(PROJECT_PATH)/swagger
HTTP_GW_PATH := $(PROJECT_PATH)/http_gateway
GOLANG_PATH := $(PROJECT_PATH)/golang
PYTHON2_PATH := $(PROJECT_PATH)/python2
PYTHON3_PATH := $(PROJECT_PATH)/python3
python2:
mkdir -p $(PYTHON2_PATH)
docker run --name py_grpc_builder -d -i -t \
-v $(PROJECT_PATH):/project \
-v $(GOPATH):/go \
-v $(PYTHON2_PATH):/out \
-w /project \
python:latest bash
docker exec -it -w /project py_grpc_builder bash scripts/py2.sh
docker rm -f py_grpc_builder
python3:
mkdir -p $(PYTHON3_PATH)
docker run --name py_grpc_builder -d -i -t \
-v $(PROJECT_PATH):/project \
-v $(PYTHON3_PATH):/out \
-w /project \
python:latest bash
docker exec -it -w /project py_grpc_builder bash scripts/py3.sh
docker rm -f py_grpc_builder
java:
mkdir -p $(JAVA_GEN_PATH)
@protoc -I$(PROTO_PATH) \
-Iinclude \
-I$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--plugin=protoc-gen-grpc-java=opt/protoc-gen-grpc-java-1.13.2-osx-x86_64.exe \
--grpc-java_out="$(JAVA_GEN_PATH)" \
--java_out="$(JAVA_GEN_PATH)" \
$(PROTO_PATH)/*.proto
@protoc -I$(PROTO_PATH) \
-Iinclude \
--java_out="$(JAVA_GEN_PATH)" \
include/scalapb/scalapb.proto
php:
mkdir -p $(PHP_GEN_PATH)
@protoc -I$(PROTO_PATH) \
-Iinclude \
--php_out=$(PHP_GEN_PATH) \
$(PROTO_PATH)/*.proto
swagger:
rm -f ${SWAGGER_PATH}/*.json
mkdir -p ${SWAGGER_PATH}
docker run -it --rm \
-v "$(shell pwd):/go/src/github.com/dialogs/api-schema" \
-v "$(SWAGGER_PATH):/out" \
-w "/go/src/github.com/dialogs/api-schema" \
dialogs/go-tools-protoc:1.0.1 \
sh -c '\
rm -rf /go/src/github.com/grpc-ecosystem/grpc-gateway && \
mkdir -p /go/src/github.com/grpc-ecosystem/grpc-gateway && \
git clone -b v1.12.2 https://github.com/grpc-ecosystem/grpc-gateway /go/src/github.com/grpc-ecosystem/grpc-gateway && \
(cd /go/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger; go install) && \
protoc \
-I=proto \
-I=include/ \
-I=/go/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--swagger_out=logtostderr=true:\
/out proto/*.proto'
golang:
# build API
rm -rf ${GOLANG_PATH}
mkdir -p ${GOLANG_PATH}
docker run -it --rm \
-v "$(shell pwd):/go/src/github.com/dialogs/api-schema" \
-w "/go/src/github.com/dialogs/api-schema" \
dialogs/go-tools-protoc:1.0.4 \
protoc \
-I=proto \
-I=include/ \
--gogoslick_out=plugins=grpc,\
Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor,\
Mscalapb/scalapb.proto=github.com/gogo/protobuf/types,\
Mgoogle/api/annotations.proto=google.golang.org/genproto/googleapis/api/annotations,\
Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types:\
./golang proto/*.proto