blob: b302c5553ff544416734ea28677cddb22a3e5964 [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)
Kailash7a70c3f2019-07-03 09:42:46 -070016VERSION ?= $(shell cat ./VERSION)
17DOCKER_TAG ?= ${VERSION}
Zack Williams86f87202018-10-05 10:36:32 -070018
Kailashd88258b2019-07-01 21:27:48 -070019## Docker related
Kailashd88258b2019-07-01 21:27:48 -070020DOCKER_BUILD_ARGS ?=
21DOCKER_TAG ?= ${VERSION}
Kailashd88258b2019-07-01 21:27:48 -070022
23## Docker labels. Only set ref and commit date if committed
24DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
25DOCKER_LABEL_VCS_REF ?= $(shell git diff-index --quiet HEAD -- && git rev-parse HEAD || echo "unknown")
26DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" )
27DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
28
Zack Williams86f87202018-10-05 10:36:32 -070029.PHONY: dep test clean docker
30
Shad Ansari573dfb82018-11-12 21:51:00 -080031prereq:
Zdravko Bozakov7401ff22019-05-28 22:45:12 +020032 go get -v google.golang.org/grpc
Shad Ansari573dfb82018-11-12 21:51:00 -080033 go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
34 go get -v github.com/golang/protobuf/protoc-gen-go
Zdravko Bozakov7401ff22019-05-28 22:45:12 +020035 go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
Shad Ansari573dfb82018-11-12 21:51:00 -080036 go get -v github.com/google/gopacket
Shad Ansari3f525132019-06-23 06:16:28 +000037 go get -u -v github.com/opencord/omci-sim
Shad Ansari573dfb82018-11-12 21:51:00 -080038
Zdravko Bozakov7401ff22019-05-28 22:45:12 +020039bbsim: prereq protos/openolt.pb.go bbsimapi dep
Zack Williams86f87202018-10-05 10:36:32 -070040 go build -i -v -o $@
41
Zdravko Bozakov7401ff22019-05-28 22:45:12 +020042dep: protos/openolt.pb.go bbsimapi
Keita NISHIMOTOca4da5f2018-10-15 22:48:52 +090043 go get -v -d ./...
Zack Williams86f87202018-10-05 10:36:32 -070044
Keita NISHIMOTO3b8b9c02018-10-09 09:40:01 +090045protos/openolt.pb.go: openolt.proto
Zack Williams86f87202018-10-05 10:36:32 -070046 @protoc -I . \
47 -I${GOPATH}/src \
48 -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
Keita NISHIMOTO3b8b9c02018-10-09 09:40:01 +090049 --go_out=plugins=grpc:protos/ \
Keita NISHIMOTOca4da5f2018-10-15 22:48:52 +090050 $<
Zack Williams86f87202018-10-05 10:36:32 -070051
Zdravko Bozakov7401ff22019-05-28 22:45:12 +020052bbsimapi: api/bbsim.proto
53 @protoc -I ./api \
54 -I${GOPATH}/src \
55 -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
56 -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway \
57 --go_out=plugins=grpc:api/ \
58 --grpc-gateway_out=logtostderr=true,allow_delete_body=true:api/ \
Shad Ansari3f525132019-06-23 06:16:28 +000059 api/bbsim.proto
Zdravko Bozakov7401ff22019-05-28 22:45:12 +020060
61swagger: ## Generate swagger documentation for BBsim API
62 @protoc -I ./api \
63 -I${GOPATH}/src \
64 -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
65 -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway \
66 --swagger_out=logtostderr=true,allow_delete_body=true:api/swagger/ \
67 bbsim.proto
68
Zack Williams86f87202018-10-05 10:36:32 -070069test:
Keita NISHIMOTOca4da5f2018-10-15 22:48:52 +090070 go test -v ./...
71 go test -v ./... -cover
72
73fmt:
74 go fmt ./...
75
76vet:
77 go vet ./...
78
79lint:
80 gometalinter --vendor --exclude ../../golang.org --skip protos --sort path --sort line ./...
Zack Williams86f87202018-10-05 10:36:32 -070081
82clean:
Zdravko Bozakov7401ff22019-05-28 22:45:12 +020083 @rm -vf bbsim \
84 protos/openolt.pb.go \
85 api/bbsim.pb.go \
86 api/bbsim.pb.gw.go \
87 api/swagger/*.json
Zack Williams86f87202018-10-05 10:36:32 -070088
Kailashd88258b2019-07-01 21:27:48 -070089docker-build:
Kailash7a70c3f2019-07-03 09:42:46 -070090 docker build -t voltha/voltha-bbsim:${DOCKER_TAG} .
91 docker save voltha/voltha-bbsim:${DOCKER_TAG} -o voltha-bbsim_${DOCKER_TAG}.tgz
Kailashd88258b2019-07-01 21:27:48 -070092
93docker-push:
Kailash7a70c3f2019-07-03 09:42:46 -070094 docker push voltha/voltha-bbsim:${DOCKER_TAG}