Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 1 | # Copyright 2019-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 | VERSION ?= $(shell cat ./VERSION) |
Matteo Scandolo | 84f7d48 | 2019-08-08 19:00:47 -0700 | [diff] [blame] | 16 | DIFF ?= $(git diff --shortstat 2> /dev/null | tail -n1) |
| 17 | GIT_STATUS ?= $(shell [[ $DIFF != "" ]] && echo "Dirty" || echo "Clean") |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 18 | |
| 19 | ## Docker related |
| 20 | DOCKER_TAG ?= ${VERSION} |
| 21 | DOCKER_REPOSITORY ?= voltha/ |
| 22 | DOCKER_REGISTRY ?= "" |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 23 | |
| 24 | # Public targets |
| 25 | |
| 26 | all: help |
| 27 | |
Matteo Scandolo | d54283a | 2019-08-13 16:22:31 -0700 | [diff] [blame] | 28 | protos: api/bbsim/bbsim.pb.go # @HELP Build proto files |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 29 | |
Matteo Scandolo | 1100699 | 2019-08-28 11:29:46 -0700 | [diff] [blame] | 30 | dep: # @HELP Download the dependencies to the vendor folder |
| 31 | GO111MODULE=on go mod vendor |
| 32 | |
Matteo Scandolo | 8df63df | 2019-09-12 10:34:32 -0700 | [diff] [blame] | 33 | build: dep protos build-bbsim build-bbsimctl# @HELP Build the binary |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 34 | |
Matteo Scandolo | 1100699 | 2019-08-28 11:29:46 -0700 | [diff] [blame] | 35 | test: dep protos # @HELP Execute unit tests |
| 36 | GO111MODULE=on go test -v -mod vendor ./internal/bbsim/... -covermode count -coverprofile ./tests/results/go-test-coverage.out 2>&1 | tee ./tests/results/go-test-results.out |
| 37 | go-junit-report < ./tests/results/go-test-results.out > ./tests/results/go-test-results.xml |
| 38 | gocover-cobertura < ./tests/results/go-test-coverage.out > ./tests/results/go-test-coverage.xml |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 39 | |
Matteo Scandolo | 84f7d48 | 2019-08-08 19:00:47 -0700 | [diff] [blame] | 40 | docker-build: # @HELP Build a docker container |
| 41 | docker build --build-arg GIT_STATUS=${GIT_STATUS} -t ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}bbsim:${DOCKER_TAG} -f build/package/Dockerfile . |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 42 | |
Matteo Scandolo | 84f7d48 | 2019-08-08 19:00:47 -0700 | [diff] [blame] | 43 | docker-push: # @HELP Push a docker container to a registry |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 44 | docker push ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}bbsim:${DOCKER_TAG} |
| 45 | |
| 46 | help: # @HELP Print the command options |
| 47 | @echo |
| 48 | @echo "\033[0;31m BroadBand Simulator (BBSim) \033[0m" |
| 49 | @echo |
| 50 | @echo Emulates the control plane of an openolt compatible device |
| 51 | @echo Useful for development and scale testing |
| 52 | @echo |
| 53 | @grep -E '^.*: .* *# *@HELP' $(MAKEFILE_LIST) \ |
| 54 | | sort \ |
| 55 | | awk ' \ |
| 56 | BEGIN {FS = ": .* *# *@HELP"}; \ |
| 57 | {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}; \ |
| 58 | ' |
| 59 | |
| 60 | |
| 61 | # Internals |
Matteo Scandolo | 8df63df | 2019-09-12 10:34:32 -0700 | [diff] [blame] | 62 | build-bbsim: |
| 63 | GO111MODULE=on go build -i -v -mod vendor \ |
| 64 | -ldflags "-X main.buildTime=$(shell date +ā%Y/%m/%d-%H:%M:%Sā) \ |
| 65 | -X main.commitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 66 | -X main.gitStatus=${GIT_STATUS} \ |
| 67 | -X main.version=${VERSION}" \ |
| 68 | -o ./cmd/bbsim ./internal/bbsim |
| 69 | |
| 70 | build-bbsimctl: |
| 71 | GO111MODULE=on go build -i -v -mod vendor \ |
| 72 | -ldflags "-X github.com/opencord/bbsim/internal/bbsimctl/config.BuildTime=$(shell date +ā%Y/%m/%d-%H:%M:%Sā) \ |
| 73 | -X github.com/opencord/bbsim/internal/bbsimctl/config.CommitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 74 | -X github.com/opencord/bbsim/internal/bbsimctl/config.GitStatus=${GIT_STATUS} \ |
| 75 | -X github.com/opencord/bbsim/internal/bbsimctl/config.Version=${VERSION}" \ |
| 76 | ./cmd/bbsimctl |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 77 | |
Matteo Scandolo | 84f7d48 | 2019-08-08 19:00:47 -0700 | [diff] [blame] | 78 | api/openolt/openolt.pb.go: api/openolt/openolt.proto |
| 79 | @protoc -I . \ |
| 80 | -I${GOPATH}/src \ |
| 81 | -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ |
| 82 | --go_out=plugins=grpc:./ \ |
| 83 | $< |
| 84 | |
| 85 | api/bbsim/bbsim.pb.go: api/bbsim/bbsim.proto |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 86 | @protoc -I . \ |
| 87 | -I${GOPATH}/src \ |
| 88 | -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ |
| 89 | --go_out=plugins=grpc:./ \ |
| 90 | $< |
| 91 | |