Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 1 | # |
| 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 | |
| 17 | SERVER_OUT := "bin/AbstractOLT" |
| 18 | CLIENT_OUT := "bin/client" |
| 19 | API_OUT := "api/abstract_olt_api.pb.go" |
| 20 | API_REST_OUT := "api/abstract_olt_api.pb.gw.go" |
| 21 | SWAGGER_OUT := "api/abstract_olt_api.swagger.json" |
| 22 | PKG := "gerrit.opencord.org/abstract-olt" |
| 23 | SERVER_PKG_BUILD := "${PKG}/cmd/AbstractOLT" |
| 24 | CLIENT_PKG_BUILD := "${PKG}/client" |
| 25 | PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/) |
Zack Williams | 34cd8f9 | 2018-09-14 16:04:19 -0700 | [diff] [blame] | 26 | DOCKERTAG ?= "latest" |
Don Newton | 276cd1f | 2019-02-06 17:14:03 -0500 | [diff] [blame] | 27 | SEBA_PROTO_PATH := contrib/xos |
| 28 | SEBA_SCHEMA_PATH := contrib/schema |
| 29 | SEBA_PROTO_FILES := $(wildcard contrib/xos/*.proto) |
| 30 | SEBA_PROTO_GO_FILES := $(foreach f,$(SEBA_PROTO_FILES),$(subst .proto,.pb.go,$(f))) |
| 31 | SEBA_PROTO_DESC_FILES := $(foreach f,$(SEBA_PROTO_FILES),$(subst .proto,.desc,$(f))) |
| 32 | |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 33 | |
Zack Williams | 34cd8f9 | 2018-09-14 16:04:19 -0700 | [diff] [blame] | 34 | .PHONY: all api server client test docker |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 35 | |
| 36 | all: server client |
| 37 | |
| 38 | api/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 | |
| 45 | api/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 Newton | 276cd1f | 2019-02-06 17:14:03 -0500 | [diff] [blame] | 52 | seba-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 | |
| 62 | schema/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 | |
donNewtonAlpha | 5234b13 | 2018-08-16 14:12:28 -0400 | [diff] [blame] | 72 | |
donNewtonAlpha | b9b85eb | 2018-08-14 14:28:22 -0400 | [diff] [blame] | 73 | |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 74 | swagger: |
donNewtonAlpha | b9b85eb | 2018-08-14 14:28:22 -0400 | [diff] [blame] | 75 | @protoc -I api/ \ |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 76 | -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 | |
| 81 | api: api/abstract_olt_api.pb.go api/abstract_olt_api.pb.gw.go swagger |
| 82 | |
| 83 | dep: ## Get the dependencies |
| 84 | @go get -v -d ./... |
| 85 | |
Don Newton | 276cd1f | 2019-02-06 17:14:03 -0500 | [diff] [blame] | 86 | server: api seba-api dep ## Build the binary file for server |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 87 | @go build -i -v -o $(SERVER_OUT) $(SERVER_PKG_BUILD) |
| 88 | |
Don Newton | 276cd1f | 2019-02-06 17:14:03 -0500 | [diff] [blame] | 89 | client: api dep## Build the binary file for client |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 90 | @go build -i -v -o $(CLIENT_OUT) $(CLIENT_PKG_BUILD) |
| 91 | |
| 92 | clean: ## Remove previous builds |
| 93 | @rm $(SERVER_OUT) $(CLIENT_OUT) $(API_OUT) $(API_REST_OUT) $(SWAGGER_OUT) |
Don Newton | 276cd1f | 2019-02-06 17:14:03 -0500 | [diff] [blame] | 94 | @rm contrib/xos/*.go |
| 95 | @rm contrib/schema/*.go |
| 96 | |
donNewtonAlpha | b9b85eb | 2018-08-14 14:28:22 -0400 | [diff] [blame] | 97 | |
| 98 | test: all |
| 99 | @go test ./... |
| 100 | @go test ./... -cover |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 101 | |
Zack Williams | 34cd8f9 | 2018-09-14 16:04:19 -0700 | [diff] [blame] | 102 | docker: ## build docker image |
| 103 | @docker build -t opencord/abstract-olt:${DOCKERTAG} . |
| 104 | |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 105 | help: ## 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}' |