Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 1 | # Copyright 2018-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | BBSIM_DEPS = $(wildcard ./*.go) |
| 16 | DOCKERTAG ?= "latest" |
Matteo Scandolo | 88e9189 | 2018-11-06 16:29:19 -0800 | [diff] [blame] | 17 | REGISTRY ?= "" |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 18 | |
| 19 | .PHONY: dep test clean docker |
| 20 | |
Shad Ansari | 573dfb8 | 2018-11-12 21:51:00 -0800 | [diff] [blame] | 21 | prereq: |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame^] | 22 | go get -v google.golang.org/grpc |
Shad Ansari | 573dfb8 | 2018-11-12 21:51:00 -0800 | [diff] [blame] | 23 | go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway |
| 24 | go get -v github.com/golang/protobuf/protoc-gen-go |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame^] | 25 | go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger |
Shad Ansari | 573dfb8 | 2018-11-12 21:51:00 -0800 | [diff] [blame] | 26 | go get -v github.com/google/gopacket |
Shad Ansari | b744bf2 | 2019-01-17 11:36:46 -0800 | [diff] [blame] | 27 | go get -v github.com/opencord/omci-sim |
Shad Ansari | 573dfb8 | 2018-11-12 21:51:00 -0800 | [diff] [blame] | 28 | |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame^] | 29 | bbsim: prereq protos/openolt.pb.go bbsimapi dep |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 30 | go build -i -v -o $@ |
| 31 | |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame^] | 32 | dep: protos/openolt.pb.go bbsimapi |
Keita NISHIMOTO | ca4da5f | 2018-10-15 22:48:52 +0900 | [diff] [blame] | 33 | go get -v -d ./... |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 34 | |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 35 | protos/openolt.pb.go: openolt.proto |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 36 | @protoc -I . \ |
| 37 | -I${GOPATH}/src \ |
| 38 | -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 39 | --go_out=plugins=grpc:protos/ \ |
Keita NISHIMOTO | ca4da5f | 2018-10-15 22:48:52 +0900 | [diff] [blame] | 40 | $< |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 41 | |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame^] | 42 | bbsimapi: api/bbsim.proto |
| 43 | @protoc -I ./api \ |
| 44 | -I${GOPATH}/src \ |
| 45 | -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ |
| 46 | -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway \ |
| 47 | --go_out=plugins=grpc:api/ \ |
| 48 | --grpc-gateway_out=logtostderr=true,allow_delete_body=true:api/ \ |
| 49 | bbsim.proto |
| 50 | |
| 51 | swagger: ## Generate swagger documentation for BBsim API |
| 52 | @protoc -I ./api \ |
| 53 | -I${GOPATH}/src \ |
| 54 | -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ |
| 55 | -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway \ |
| 56 | --swagger_out=logtostderr=true,allow_delete_body=true:api/swagger/ \ |
| 57 | bbsim.proto |
| 58 | |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 59 | test: |
Keita NISHIMOTO | ca4da5f | 2018-10-15 22:48:52 +0900 | [diff] [blame] | 60 | go test -v ./... |
| 61 | go test -v ./... -cover |
| 62 | |
| 63 | fmt: |
| 64 | go fmt ./... |
| 65 | |
| 66 | vet: |
| 67 | go vet ./... |
| 68 | |
| 69 | lint: |
| 70 | gometalinter --vendor --exclude ../../golang.org --skip protos --sort path --sort line ./... |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 71 | |
| 72 | clean: |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame^] | 73 | @rm -vf bbsim \ |
| 74 | protos/openolt.pb.go \ |
| 75 | api/bbsim.pb.go \ |
| 76 | api/bbsim.pb.gw.go \ |
| 77 | api/swagger/*.json |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 78 | |
| 79 | docker: |
Matteo Scandolo | 88e9189 | 2018-11-06 16:29:19 -0800 | [diff] [blame] | 80 | docker build -t ${REGISTRY}voltha/voltha-bbsim:${DOCKERTAG} . |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame^] | 81 | docker save voltha/voltha-bbsim:${DOCKERTAG} -o voltha-bbsim_${DOCKERTAG}.tgz |