blob: a0e9b5c6e85c33f0c334fe7637a385b6b7797c66 [file] [log] [blame]
Author Namea594e632018-08-10 11:33:58 -04001#
2# Copyright 2017 the original author or authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17SERVER_OUT := "bin/AbstractOLT"
18CLIENT_OUT := "bin/client"
19API_OUT := "api/abstract_olt_api.pb.go"
20API_REST_OUT := "api/abstract_olt_api.pb.gw.go"
21SWAGGER_OUT := "api/abstract_olt_api.swagger.json"
22PKG := "gerrit.opencord.org/abstract-olt"
23SERVER_PKG_BUILD := "${PKG}/cmd/AbstractOLT"
24CLIENT_PKG_BUILD := "${PKG}/client"
25PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040026DOCKERTAG ?= "latest"
Author Namea594e632018-08-10 11:33:58 -040027
28
donNewtonAlpha5234b132018-08-16 14:12:28 -040029.PHONY: all api server client test
Author Namea594e632018-08-10 11:33:58 -040030
31all: server client
32
33api/abstract_olt_api.pb.go:
34 @protoc -I api/ \
35 -I${GOPATH}/src \
36 -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
37 --go_out=plugins=grpc:api \
38 api/abstract_olt_api.proto
39
40api/abstract_olt_api.pb.gw.go :
41 @protoc -I api/ \
42 -I${GOPATH}/src \
43 -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
44 --grpc-gateway_out=logtostderr=true:api \
45 api/abstract_olt_api.proto
46
donNewtonAlpha5234b132018-08-16 14:12:28 -040047api/xos.pb.go:
48 @protoc -I seba-api/ \
49 -I${GOPATH}/src \
50 -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
51 -I${GOPATH}/src/github.com/googleapis/google/api \
52 -I${GOPATH}/src/github.com/googleapis/ \
53 --go_out=plugins=grpc:seba-api \
54 seba-api/xos.proto
55
donNewtonAlphab9b85eb2018-08-14 14:28:22 -040056
Author Namea594e632018-08-10 11:33:58 -040057swagger:
donNewtonAlphab9b85eb2018-08-14 14:28:22 -040058 @protoc -I api/ \
Author Namea594e632018-08-10 11:33:58 -040059 -I${GOPATH}/src \
60 -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
61 --swagger_out=logtostderr=true:api \
62 api/abstract_olt_api.proto
63
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040064docker: ## build docker image
65 @docker build -t sebaproject/abstract-olt:${DOCKERTAG} .
66
Author Namea594e632018-08-10 11:33:58 -040067api: api/abstract_olt_api.pb.go api/abstract_olt_api.pb.gw.go swagger
68
69dep: ## Get the dependencies
70 @go get -v -d ./...
71
72server: dep api ## Build the binary file for server
73 @go build -i -v -o $(SERVER_OUT) $(SERVER_PKG_BUILD)
74
75client: dep api ## Build the binary file for client
76 @go build -i -v -o $(CLIENT_OUT) $(CLIENT_PKG_BUILD)
77
78clean: ## Remove previous builds
79 @rm $(SERVER_OUT) $(CLIENT_OUT) $(API_OUT) $(API_REST_OUT) $(SWAGGER_OUT)
donNewtonAlphab9b85eb2018-08-14 14:28:22 -040080 @rm -rf seba-api
81
82test: all
83 @go test ./...
84 @go test ./... -cover
Author Namea594e632018-08-10 11:33:58 -040085
86help: ## Display this help screen
87 @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'