11PROTOC_VERSION := 3.9.2
22PROTOC_WEB_VERSION := 1.0.6
3+
34PROTO_SOURCES := -I /usr/local/include
45PROTO_SOURCES += -I .
56PROTO_SOURCES += -I ${GOPATH}/src
67PROTO_SOURCES += -I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis
8+ PROTO_SOURCES += -I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway
79
8- deps-linux : deps-protoc-linux deps-grpc-web-linux
10+ deps-linux : deps-protoc-linux deps-grpc-web-linux deps-go
911
1012deps-protoc-linux :
1113 curl -OL https://github.com/google/protobuf/releases/download/v$(PROTOC_VERSION ) /protoc-$(PROTOC_VERSION ) -linux-x86_64.zip
@@ -19,9 +21,14 @@ deps-grpc-web-linux:
1921 sudo mv protoc-gen-grpc-web-$(PROTOC_WEB_VERSION ) -linux-x86_64 /usr/local/bin/protoc-gen-grpc-web
2022 chmod +x /usr/local/bin/protoc-gen-grpc-web
2123
22- generate : generate-grpc generate-web
24+ deps-go :
25+ go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
26+ go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
27+ go get -u github.com/golang/protobuf/protoc-gen-go
28+
29+ generate : generate-grpc generate-web generate-http
2330
24- generate-grpc :
31+ generate-grpc :
2532 mkdir -p gen/go
2633 protoc ${PROTO_SOURCES} --go_out=plugins=grpc:./gen/go ./proto/health/* .proto
2734 protoc ${PROTO_SOURCES} --go_out=plugins=grpc:./gen/go ./proto/helloworld/* .proto
@@ -33,4 +40,11 @@ generate-web:
3340 protoc ${PROTO_SOURCES} --grpc-web_out=import_style=typescript,mode=grpcwebtext:gen/web ./proto/helloworld/* .proto
3441 cp -f -rv gen/web/proto/* gen/web
3542 rm -rf gen/web/Proto gen/web/proto
43+ generate-http :
44+ mkdir -p gen/http gen/swagger
45+ protoc ${PROTO_SOURCES} --grpc-gateway_out=logtostderr=true:gen/http --swagger_out=logtostderr=true:gen/swagger ./proto/health/* .proto
46+ protoc ${PROTO_SOURCES} --grpc-gateway_out=logtostderr=true:gen/http --swagger_out=logtostderr=true:gen/swagger ./proto/helloworld/* .proto
47+ cp -f -rv gen/http/proto/* gen/http
48+ cp -f -rv gen/swagger/proto/* gen/swagger
49+ rm -rf gen/swagger/proto
3650
0 commit comments