blob: e2c024237a65b40d0927e70bfdd56ef2d7ffc351 [file] [log] [blame]
Zack Williams86f87202018-10-05 10:36:32 -07001# 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
15BBSIM_DEPS = $(wildcard ./*.go)
16DOCKERTAG ?= "latest"
Matteo Scandolo88e91892018-11-06 16:29:19 -080017REGISTRY ?= ""
Zack Williams86f87202018-10-05 10:36:32 -070018
19.PHONY: dep test clean docker
20
Shad Ansari573dfb82018-11-12 21:51:00 -080021prereq:
Zdravko Bozakov7401ff22019-05-28 22:45:12 +020022 go get -v google.golang.org/grpc
Shad Ansari573dfb82018-11-12 21:51:00 -080023 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 Bozakov7401ff22019-05-28 22:45:12 +020025 go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
Shad Ansari573dfb82018-11-12 21:51:00 -080026 go get -v github.com/google/gopacket
Shad Ansarib744bf22019-01-17 11:36:46 -080027 go get -v github.com/opencord/omci-sim
Shad Ansari573dfb82018-11-12 21:51:00 -080028
Zdravko Bozakov7401ff22019-05-28 22:45:12 +020029bbsim: prereq protos/openolt.pb.go bbsimapi dep
Zack Williams86f87202018-10-05 10:36:32 -070030 go build -i -v -o $@
31
Zdravko Bozakov7401ff22019-05-28 22:45:12 +020032dep: protos/openolt.pb.go bbsimapi
Keita NISHIMOTOca4da5f2018-10-15 22:48:52 +090033 go get -v -d ./...
Zack Williams86f87202018-10-05 10:36:32 -070034
Keita NISHIMOTO3b8b9c02018-10-09 09:40:01 +090035protos/openolt.pb.go: openolt.proto
Zack Williams86f87202018-10-05 10:36:32 -070036 @protoc -I . \
37 -I${GOPATH}/src \
38 -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
Keita NISHIMOTO3b8b9c02018-10-09 09:40:01 +090039 --go_out=plugins=grpc:protos/ \
Keita NISHIMOTOca4da5f2018-10-15 22:48:52 +090040 $<
Zack Williams86f87202018-10-05 10:36:32 -070041
Zdravko Bozakov7401ff22019-05-28 22:45:12 +020042bbsimapi: 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
51swagger: ## 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 Williams86f87202018-10-05 10:36:32 -070059test:
Keita NISHIMOTOca4da5f2018-10-15 22:48:52 +090060 go test -v ./...
61 go test -v ./... -cover
62
63fmt:
64 go fmt ./...
65
66vet:
67 go vet ./...
68
69lint:
70 gometalinter --vendor --exclude ../../golang.org --skip protos --sort path --sort line ./...
Zack Williams86f87202018-10-05 10:36:32 -070071
72clean:
Zdravko Bozakov7401ff22019-05-28 22:45:12 +020073 @rm -vf bbsim \
74 protos/openolt.pb.go \
75 api/bbsim.pb.go \
76 api/bbsim.pb.gw.go \
77 api/swagger/*.json
Zack Williams86f87202018-10-05 10:36:32 -070078
79docker:
Matteo Scandolo88e91892018-11-06 16:29:19 -080080 docker build -t ${REGISTRY}voltha/voltha-bbsim:${DOCKERTAG} .
Zdravko Bozakov7401ff22019-05-28 22:45:12 +020081 docker save voltha/voltha-bbsim:${DOCKERTAG} -o voltha-bbsim_${DOCKERTAG}.tgz