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 | |
Zack Williams | 2abf393 | 2019-08-05 14:07:05 -0700 | [diff] [blame] | 15 | VERSION ?= $(shell cat ./VERSION) |
| 16 | BBSIM_DEPS = $(wildcard ./*.go) |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 17 | |
Kailash | d88258b | 2019-07-01 21:27:48 -0700 | [diff] [blame] | 18 | ## Docker related |
Zack Williams | 2abf393 | 2019-08-05 14:07:05 -0700 | [diff] [blame] | 19 | DOCKER_REGISTRY ?= "" |
| 20 | DOCKER_REPOSITORY ?= voltha/ |
Kailash | d88258b | 2019-07-01 21:27:48 -0700 | [diff] [blame] | 21 | DOCKER_BUILD_ARGS ?= |
| 22 | DOCKER_TAG ?= ${VERSION} |
Zack Williams | 2abf393 | 2019-08-05 14:07:05 -0700 | [diff] [blame] | 23 | BBSIM_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-bbsim:${DOCKER_TAG} |
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 | |
Zdravko Bozakov | d52eaee | 2019-09-18 12:24:13 +0200 | [diff] [blame] | 31 | GRPC_GW_PATH ?= $(shell GO111MODULE=on go list -f '{{ .Dir }}' -m github.com/grpc-ecosystem/grpc-gateway) |
Zdravko Bozakov | 078a271 | 2019-07-19 23:25:15 +0200 | [diff] [blame] | 32 | PROTO_PATH ?= $(shell GO111MODULE=on go list -f '{{ .Dir }}' -m github.com/opencord/voltha-protos) |
Zdravko Bozakov | d52eaee | 2019-09-18 12:24:13 +0200 | [diff] [blame] | 33 | |
Matt Jeanneret | 7c9c5f2 | 2019-08-09 14:40:12 -0400 | [diff] [blame] | 34 | bbsim: dep bbsimapi |
Matteo Scandolo | f7b260d | 2019-07-31 13:43:02 -0700 | [diff] [blame] | 35 | GO111MODULE=on go build -i -v -o $@ |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 36 | |
Matteo Scandolo | f7b260d | 2019-07-31 13:43:02 -0700 | [diff] [blame] | 37 | dep: |
Zdravko Bozakov | d52eaee | 2019-09-18 12:24:13 +0200 | [diff] [blame] | 38 | GO111MODULE=on go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.9.5 |
Matteo Scandolo | f7b260d | 2019-07-31 13:43:02 -0700 | [diff] [blame] | 39 | GO111MODULE=on go mod download all |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 40 | |
Zdravko Bozakov | d52eaee | 2019-09-18 12:24:13 +0200 | [diff] [blame] | 41 | |
| 42 | bbsimapi: dep api/bbsim.pb.go api/bbsim.pb.gw.go |
| 43 | @echo using ${GRPC_GW_PATH} |
| 44 | |
| 45 | api/bbsim.pb.go api/bbsim.pb.gw.go: api/bbsim.proto |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame] | 46 | @protoc -I ./api \ |
Zdravko Bozakov | d52eaee | 2019-09-18 12:24:13 +0200 | [diff] [blame] | 47 | -I${GRPC_GW_PATH}/third_party/googleapis/ \ |
| 48 | -I${GRPC_GW_PATH}/ \ |
Zdravko Bozakov | 078a271 | 2019-07-19 23:25:15 +0200 | [diff] [blame] | 49 | -I${PROTO_PATH}/protos/ \ |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame] | 50 | --go_out=plugins=grpc:api/ \ |
| 51 | --grpc-gateway_out=logtostderr=true,allow_delete_body=true:api/ \ |
Shad Ansari | 3f52513 | 2019-06-23 06:16:28 +0000 | [diff] [blame] | 52 | api/bbsim.proto |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame] | 53 | |
| 54 | swagger: ## Generate swagger documentation for BBsim API |
| 55 | @protoc -I ./api \ |
Zdravko Bozakov | d52eaee | 2019-09-18 12:24:13 +0200 | [diff] [blame] | 56 | -I${GRPC_GW_PATH}/third_party/googleapis/ \ |
| 57 | -I${GRPC_GW_PATH}/ \ |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame] | 58 | --swagger_out=logtostderr=true,allow_delete_body=true:api/swagger/ \ |
Zdravko Bozakov | 078a271 | 2019-07-19 23:25:15 +0200 | [diff] [blame] | 59 | api/bbsim.proto |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame] | 60 | |
Matt Jeanneret | 7c9c5f2 | 2019-08-09 14:40:12 -0400 | [diff] [blame] | 61 | test: dep bbsimapi |
Matteo Scandolo | f7b260d | 2019-07-31 13:43:02 -0700 | [diff] [blame] | 62 | GO111MODULE=on go test -v ./... |
| 63 | GO111MODULE=on go test -v ./... -cover |
Keita NISHIMOTO | ca4da5f | 2018-10-15 22:48:52 +0900 | [diff] [blame] | 64 | |
| 65 | fmt: |
| 66 | go fmt ./... |
| 67 | |
| 68 | vet: |
| 69 | go vet ./... |
| 70 | |
| 71 | lint: |
| 72 | gometalinter --vendor --exclude ../../golang.org --skip protos --sort path --sort line ./... |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 73 | |
| 74 | clean: |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame] | 75 | @rm -vf bbsim \ |
Zdravko Bozakov | d52eaee | 2019-09-18 12:24:13 +0200 | [diff] [blame] | 76 | api/bbsim.pb.go \ |
Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame] | 77 | api/bbsim.pb.gw.go \ |
| 78 | api/swagger/*.json |
Zack Williams | 86f8720 | 2018-10-05 10:36:32 -0700 | [diff] [blame] | 79 | |
Kailash | d88258b | 2019-07-01 21:27:48 -0700 | [diff] [blame] | 80 | docker-build: |
Zack Williams | 2abf393 | 2019-08-05 14:07:05 -0700 | [diff] [blame] | 81 | docker build ${DOCKER_BUILD_ARGS} -t ${BBSIM_IMAGENAME} . |
Matteo Scandolo | f7b260d | 2019-07-31 13:43:02 -0700 | [diff] [blame] | 82 | |
| 83 | docker-save: |
Zack Williams | 2abf393 | 2019-08-05 14:07:05 -0700 | [diff] [blame] | 84 | docker save ${BBSIM_IMAGENAME} -o voltha-bbsim_${DOCKER_TAG}.tgz |
Kailash | d88258b | 2019-07-01 21:27:48 -0700 | [diff] [blame] | 85 | |
| 86 | docker-push: |
Zack Williams | 2abf393 | 2019-08-05 14:07:05 -0700 | [diff] [blame] | 87 | docker push ${BBSIM_IMAGENAME} |