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