aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorCarlos Sosa <gnusosa@gnusosa.net>2020-06-22 11:33:39 -0700
committerCarlos Sosa <gnusosa@gnusosa.net>2020-06-22 11:33:39 -0700
commit0b609156b184d00ab1a6e742b9b998be4457345e (patch)
tree9283646735cf0f7a984ff0fe4013f6abc7a8be4f /Makefile
First Commit
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile45
1 files changed, 45 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..2d08551
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,45 @@
+SERVER_OUT := "bin/server"
+CLIENT_OUT := "../bin/client"
+API_OUT := "api/api.pb.go"
+API_REST_OUT := "api/api.pb.gw.go"
+API_SWAG_OUT := "api/api.swagger.json"
+CLIENT_PKG_BUILD := "client/"
+
+.PHONY: all api server client
+
+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.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.swagger.json: api/api.proto
+ @protoc -I api/ \
+ -I${GOPATH}/src \
+ -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
+ --swagger_out=logtostderr=true:api \
+ api/api.proto
+
+api: api/api.pb.go api/api.pb.gw.go api/api.swagger.json ## Auto-generate grpc go sources
+
+server: api ## Build the binary file for server
+ @go build -i -v -o $(SERVER_OUT)
+
+client: api ## Build the binary file for client
+ @cd client; go build -i -v -o $(CLIENT_OUT)
+
+clean: ## Remove previous builds
+ @rm $(SERVER_OUT) $(CLIENT_OUT) $(API_OUT) $(API_REST_OUT) $(API_SWAG_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}'