From: Julien Andrieux Date: Wed, 4 Oct 2017 23:15:59 +0000 (+0200) Subject: Makefile to build client, server and generate api go code X-Git-Url: https://git.halfball.org/?a=commitdiff_plain;h=c06c77e20581145a9f559e408809b17f8b5504f6;p=demo-grpc.git Makefile to build client, server and generate api go code --- diff --git a/.gitignore b/.gitignore index fbedee5..c0edc89 100644 --- a/.gitignore +++ b/.gitignore @@ -84,4 +84,7 @@ GitHub.sublime-settings # Compiled protobuf files *.pb.go *.pb.gw.go -*.swagger.json \ No newline at end of file +*.swagger.json + +# Binaries generated by Makefile +bin/* \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..df9f6a6 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +SERVER_OUT := "bin/server" +CLIENT_OUT := "bin/client" +API_OUT := "api/api.pb.go" +PKG := "gitlab.com/pantomath-io/demo-grpc" +SERVER_PKG_BUILD := "${PKG}/server" +CLIENT_PKG_BUILD := "${PKG}/client" +PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/) + +.PHONY: all api server client + +all: server client + +api/api.pb.go: api/api.proto + @protoc -I api/ \ + -I${GOPATH}/src \ + --go_out=plugins=grpc:api \ + api/api.proto + +api: api/api.pb.go ## Auto-generate grpc go sources + +dep: ## Get the dependencies + @go get -v -d ./... + +server: dep api ## Build the binary file for server + @go build -i -v -o $(SERVER_OUT) $(SERVER_PKG_BUILD) + +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) + +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}'