blob: 146ad3d331b9d7bfecdf3ec9590e7f22e5de783a [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/)
Zack Williams34cd8f92018-09-14 16:04:19 -070026DOCKERTAG ?= "latest"
Don Newton276cd1f2019-02-06 17:14:03 -050027SEBA_PROTO_PATH := contrib/xos
28SEBA_SCHEMA_PATH := contrib/schema
29SEBA_PROTO_FILES := $(wildcard contrib/xos/*.proto)
30SEBA_PROTO_GO_FILES := $(foreach f,$(SEBA_PROTO_FILES),$(subst .proto,.pb.go,$(f)))
31SEBA_PROTO_DESC_FILES := $(foreach f,$(SEBA_PROTO_FILES),$(subst .proto,.desc,$(f)))
32
Author Namea594e632018-08-10 11:33:58 -040033
Zack Williams34cd8f92018-09-14 16:04:19 -070034.PHONY: all api server client test docker
Author Namea594e632018-08-10 11:33:58 -040035
36all: server client
37
38api/abstract_olt_api.pb.go:
39 @protoc -I api/ \
40 -I${GOPATH}/src \
41 -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
42 --go_out=plugins=grpc:api \
43 api/abstract_olt_api.proto
44
45api/abstract_olt_api.pb.gw.go :
46 @protoc -I api/ \
47 -I${GOPATH}/src \
48 -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
49 --grpc-gateway_out=logtostderr=true:api \
50 api/abstract_olt_api.proto
51
Don Newton276cd1f2019-02-06 17:14:03 -050052seba-api: schema/schema.pb.go $(SEBA_PROTO_GO_FILES)
53
54%.pb.go: %.proto
55 @protoc -I ${SEBA_PROTO_PATH} \
56 -I ${SEBA_SCHEMA_PATH} \
57 --go_out=plugins=grpc:${SEBA_PROTO_PATH} \
58 -I${GOPATH}/src \
59 -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
60 $<
61
62schema/schema.pb.go:
63 @protoc -I ${SEBA_PROTO_PATH} \
64 -I ${SEBA_SCHEMA_PATH} \
65 --go_out=plugins=grpc:${SEBA_SCHEMA_PATH} \
66 -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
67 --descriptor_set_out=${SEBA_SCHEMA_PATH}/schema.desc \
68 --include_imports \
69 --include_source_info \
70 ${SEBA_SCHEMA_PATH}/schema.proto
71
donNewtonAlpha5234b132018-08-16 14:12:28 -040072
donNewtonAlphab9b85eb2018-08-14 14:28:22 -040073
Author Namea594e632018-08-10 11:33:58 -040074swagger:
donNewtonAlphab9b85eb2018-08-14 14:28:22 -040075 @protoc -I api/ \
Author Namea594e632018-08-10 11:33:58 -040076 -I${GOPATH}/src \
77 -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
78 --swagger_out=logtostderr=true:api \
79 api/abstract_olt_api.proto
80
81api: api/abstract_olt_api.pb.go api/abstract_olt_api.pb.gw.go swagger
82
83dep: ## Get the dependencies
84 @go get -v -d ./...
85
Don Newton276cd1f2019-02-06 17:14:03 -050086server: api seba-api dep ## Build the binary file for server
Author Namea594e632018-08-10 11:33:58 -040087 @go build -i -v -o $(SERVER_OUT) $(SERVER_PKG_BUILD)
88
Don Newton276cd1f2019-02-06 17:14:03 -050089client: api dep## Build the binary file for client
Author Namea594e632018-08-10 11:33:58 -040090 @go build -i -v -o $(CLIENT_OUT) $(CLIENT_PKG_BUILD)
91
92clean: ## Remove previous builds
93 @rm $(SERVER_OUT) $(CLIENT_OUT) $(API_OUT) $(API_REST_OUT) $(SWAGGER_OUT)
Don Newton276cd1f2019-02-06 17:14:03 -050094 @rm contrib/xos/*.go
95 @rm contrib/schema/*.go
96
donNewtonAlphab9b85eb2018-08-14 14:28:22 -040097
98test: all
99 @go test ./...
100 @go test ./... -cover
Author Namea594e632018-08-10 11:33:58 -0400101
Zack Williams34cd8f92018-09-14 16:04:19 -0700102docker: ## build docker image
103 @docker build -t opencord/abstract-olt:${DOCKERTAG} .
104
Author Namea594e632018-08-10 11:33:58 -0400105help: ## Display this help screen
106 @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'