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