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) |
Kailash | 3150a01 | 2019-07-02 12:27:44 -0700 | [diff] [blame^] | 16 | DOCKER_TAG ?= "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 | |
Kailash | d88258b | 2019-07-01 21:27:48 -0700 | [diff] [blame] | 19 | ## Docker related |
| 20 | DOCKER_REGISTRY ?= |
| 21 | DOCKER_REPOSITORY ?= |
| 22 | DOCKER_BUILD_ARGS ?= |
| 23 | DOCKER_TAG ?= ${VERSION} |
| 24 | DOCKER_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${SYNCHRONIZER_NAME}:${DOCKER_TAG} |
| 25 | |
| 26 | ## Docker labels. Only set ref and commit date if committed |
| 27 | DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote)) |
| 28 | DOCKER_LABEL_VCS_REF ?= $(shell git diff-index --quiet HEAD -- && git rev-parse HEAD || echo "unknown") |
| 29 | DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" ) |
| 30 | DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ") |
| 31 | |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 32 | .PHONY: dep test clean docker |
| 33 | |
Shad Ansari | 573dfb8 | 2018-11-12 21:51:00 -0800 | [diff] [blame] | 34 | prereq: |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame] | 35 | go get -v google.golang.org/grpc |
Shad Ansari | 573dfb8 | 2018-11-12 21:51:00 -0800 | [diff] [blame] | 36 | go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway |
| 37 | go get -v github.com/golang/protobuf/protoc-gen-go |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame] | 38 | go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger |
Shad Ansari | 573dfb8 | 2018-11-12 21:51:00 -0800 | [diff] [blame] | 39 | go get -v github.com/google/gopacket |
Shad Ansari | 3f52513 | 2019-06-23 06:16:28 +0000 | [diff] [blame] | 40 | go get -u -v github.com/opencord/omci-sim |
Shad Ansari | 573dfb8 | 2018-11-12 21:51:00 -0800 | [diff] [blame] | 41 | |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame] | 42 | bbsim: prereq protos/openolt.pb.go bbsimapi dep |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 43 | go build -i -v -o $@ |
| 44 | |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame] | 45 | dep: protos/openolt.pb.go bbsimapi |
Keita NISHIMOTO | ca4da5f | 2018-10-15 22:48:52 +0900 | [diff] [blame] | 46 | go get -v -d ./... |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 47 | |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 48 | protos/openolt.pb.go: openolt.proto |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 49 | @protoc -I . \ |
| 50 | -I${GOPATH}/src \ |
| 51 | -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 52 | --go_out=plugins=grpc:protos/ \ |
Keita NISHIMOTO | ca4da5f | 2018-10-15 22:48:52 +0900 | [diff] [blame] | 53 | $< |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 54 | |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame] | 55 | bbsimapi: api/bbsim.proto |
| 56 | @protoc -I ./api \ |
| 57 | -I${GOPATH}/src \ |
| 58 | -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ |
| 59 | -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway \ |
| 60 | --go_out=plugins=grpc:api/ \ |
| 61 | --grpc-gateway_out=logtostderr=true,allow_delete_body=true:api/ \ |
Shad Ansari | 3f52513 | 2019-06-23 06:16:28 +0000 | [diff] [blame] | 62 | api/bbsim.proto |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame] | 63 | |
| 64 | swagger: ## Generate swagger documentation for BBsim API |
| 65 | @protoc -I ./api \ |
| 66 | -I${GOPATH}/src \ |
| 67 | -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ |
| 68 | -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway \ |
| 69 | --swagger_out=logtostderr=true,allow_delete_body=true:api/swagger/ \ |
| 70 | bbsim.proto |
| 71 | |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 72 | test: |
Keita NISHIMOTO | ca4da5f | 2018-10-15 22:48:52 +0900 | [diff] [blame] | 73 | go test -v ./... |
| 74 | go test -v ./... -cover |
| 75 | |
| 76 | fmt: |
| 77 | go fmt ./... |
| 78 | |
| 79 | vet: |
| 80 | go vet ./... |
| 81 | |
| 82 | lint: |
| 83 | gometalinter --vendor --exclude ../../golang.org --skip protos --sort path --sort line ./... |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 84 | |
| 85 | clean: |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame] | 86 | @rm -vf bbsim \ |
| 87 | protos/openolt.pb.go \ |
| 88 | api/bbsim.pb.go \ |
| 89 | api/bbsim.pb.gw.go \ |
| 90 | api/swagger/*.json |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 91 | |
Kailash | d88258b | 2019-07-01 21:27:48 -0700 | [diff] [blame] | 92 | docker-build: |
Matteo Scandolo | 88e9189 | 2018-11-06 16:29:19 -0800 | [diff] [blame] | 93 | docker build -t ${REGISTRY}voltha/voltha-bbsim:${DOCKERTAG} . |
Kailash | 3150a01 | 2019-07-02 12:27:44 -0700 | [diff] [blame^] | 94 | docker save voltha/voltha-bbsim:${DOCKER_TAG} -o voltha-bbsim_${DOCKERTAG}.tgz |
Kailash | d88258b | 2019-07-01 21:27:48 -0700 | [diff] [blame] | 95 | |
| 96 | docker-push: |
| 97 | docker push ${DOCKER_IMAGENAME} |