Add target for the new protoc compilation
authorJulien Andrieux <julien@pantomath.io>
Fri, 6 Oct 2017 14:19:00 +0000 (16:19 +0200)
committerJulien Andrieux <julien@pantomath.io>
Fri, 6 Oct 2017 14:19:00 +0000 (16:19 +0200)
Makefile

index df9f6a6..52fff7f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
 SERVER_OUT := "bin/server"
 CLIENT_OUT := "bin/client"
 API_OUT := "api/api.pb.go"
+API_REST_OUT := "api/api.pb.gw.go"
 PKG := "gitlab.com/pantomath-io/demo-grpc"
 SERVER_PKG_BUILD := "${PKG}/server"
 CLIENT_PKG_BUILD := "${PKG}/client"
@@ -13,10 +14,18 @@ all: server client
 api/api.pb.go: api/api.proto
        @protoc -I api/ \
                -I${GOPATH}/src \
+               -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
                --go_out=plugins=grpc:api \
                api/api.proto
 
-api: api/api.pb.go ## Auto-generate grpc go sources
+api/api.pb.gw.go: api/api.proto
+       @protoc -I api/ \
+               -I${GOPATH}/src \
+               -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
+               --grpc-gateway_out=logtostderr=true:api \
+               api/api.proto
+
+api: api/api.pb.go api/api.pb.gw.go ## Auto-generate grpc go sources
 
 dep: ## Get the dependencies
        @go get -v -d ./...
@@ -28,7 +37,7 @@ client: dep api ## Build the binary file for client
        @go build -i -v -o $(CLIENT_OUT) $(CLIENT_PKG_BUILD)
 
 clean: ## Remove previous builds
-       @rm $(SERVER_OUT) $(CLIENT_OUT) $(API_OUT)
+       @rm $(SERVER_OUT) $(CLIENT_OUT) $(API_OUT) $(API_REST_OUT)
 
 help: ## Display this help screen
        @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'