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 | |
Matteo Scandolo | 0b603aa | 2020-08-21 14:40:48 -0700 | [diff] [blame] | 15 | SHELL = bash -e -o pipefail |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 16 | VERSION ?= $(shell cat ./VERSION) |
Matteo Scandolo | 84f7d48 | 2019-08-08 19:00:47 -0700 | [diff] [blame] | 17 | DIFF ?= $(git diff --shortstat 2> /dev/null | tail -n1) |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 18 | GIT_STATUS ?= $(shell [ -z "$DIFF" ] && echo "Dirty" || echo "Clean") |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 19 | |
| 20 | ## Docker related |
| 21 | DOCKER_TAG ?= ${VERSION} |
Matteo Scandolo | 5daa2ab | 2019-10-08 08:27:18 -0700 | [diff] [blame] | 22 | DOCKER_REPOSITORY ?= "" |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 23 | DOCKER_REGISTRY ?= "" |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 24 | DOCKER_RUN_ARGS ?= "" |
Andrea Campanella | d683d16 | 2020-10-13 16:40:27 +0200 | [diff] [blame] | 25 | DOCKER_PORTS ?= -p 50070:50070 -p 50060:50060 -p 50071:50071 -p 50072:50072 -p 50073:50073 -p 50074:50074 -p 50075:50075 |
Andrea Campanella | 64dffd5 | 2019-12-17 17:29:57 -0800 | [diff] [blame] | 26 | TYPE ?= minimal |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 27 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 28 | # tool containers |
Matteo Scandolo | 34a9ea3 | 2020-11-19 17:40:49 -0800 | [diff] [blame] | 29 | VOLTHA_TOOLS_VERSION ?= 2.3.1 |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 30 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 31 | GO = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") -v gocache:/.cache -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-golang go |
| 32 | GO_SH = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") -v gocache:/.cache -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-golang sh -c ' |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 33 | GO_JUNIT_REPORT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app -i voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-go-junit-report go-junit-report |
Matteo Scandolo | 34a9ea3 | 2020-11-19 17:40:49 -0800 | [diff] [blame] | 34 | GOCOVER_COBERTURA = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app/src/github.com/opencord/bbsim -i voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-gocover-cobertura gocover-cobertura |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 35 | GOLANGCI_LINT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") -v gocache:/.cache -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-golangci-lint golangci-lint |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 36 | HADOLINT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-hadolint hadolint |
| 37 | PROTOC = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-protoc protoc |
| 38 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 39 | # Public targets |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 40 | all: help |
| 41 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 42 | protos: api/bbsim/bbsim.pb.go api/bbsim/bbsim.pb.gw.go api/legacy/bbsim.pb.go api/legacy/bbsim.pb.gw.go # @HELP Build proto files |
Matteo Scandolo | 01d41ce | 2019-10-28 15:42:47 -0700 | [diff] [blame] | 43 | |
Matteo Scandolo | 6866b8c | 2019-10-28 16:15:24 -0700 | [diff] [blame] | 44 | .PHONY: build |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 45 | build: protos build-bbsim build-bbsimctl build-bbr |
| 46 | |
| 47 | ## lint and unit tests |
| 48 | |
| 49 | lint-dockerfile: |
| 50 | @echo "Running Dockerfile lint check..." |
| 51 | @${HADOLINT} $$(find ./build -name "Dockerfile*") |
| 52 | @echo "Dockerfile lint check OK" |
| 53 | |
| 54 | lint-mod: |
| 55 | @echo "Running dependency check..." |
| 56 | @${GO} mod verify |
| 57 | @echo "Dependency check OK. Running vendor check..." |
| 58 | @git status > /dev/null |
| 59 | @git diff-index --quiet HEAD -- go.mod go.sum vendor || (echo "ERROR: Staged or modified files must be committed before running this test" && git status -- go.mod go.sum vendor && exit 1) |
| 60 | @[[ `git ls-files --exclude-standard --others go.mod go.sum vendor` == "" ]] || (echo "ERROR: Untracked files must be cleaned up before running this test" && git status -- go.mod go.sum vendor && exit 1) |
| 61 | ${GO} mod tidy |
| 62 | ${GO} mod vendor |
| 63 | @git status > /dev/null |
| 64 | @git diff-index --quiet HEAD -- go.mod go.sum vendor || (echo "ERROR: Modified files detected after running go mod tidy / go mod vendor" && git status -- go.mod go.sum vendor && git checkout -- go.mod go.sum vendor && exit 1) |
| 65 | @[[ `git ls-files --exclude-standard --others go.mod go.sum vendor` == "" ]] || (echo "ERROR: Untracked files detected after running go mod tidy / go mod vendor" && git status -- go.mod go.sum vendor && git checkout -- go.mod go.sum vendor && exit 1) |
| 66 | @echo "Vendor check OK." |
| 67 | |
| 68 | lint: lint-mod lint-dockerfile |
| 69 | |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 70 | sca: |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 71 | @rm -rf ./sca-report |
| 72 | @mkdir -p ./sca-report |
| 73 | @echo "Running static code analysis..." |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 74 | @${GOLANGCI_LINT} run --deadline=4m --out-format junit-xml ./... | tee ./sca-report/sca-report.xml |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 75 | @echo "" |
| 76 | @echo "Static code analysis OK" |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 77 | |
Matteo Scandolo | 0e9fabf | 2020-09-30 17:19:27 -0700 | [diff] [blame] | 78 | test: docs-lint test-unit test-bbr |
Matteo Scandolo | 569e717 | 2019-12-20 11:51:51 -0800 | [diff] [blame] | 79 | |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 80 | test-unit: clean local-omci-sim # @HELP Execute unit tests |
| 81 | @echo "Running unit tests..." |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 82 | @mkdir -p ./tests/results |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 83 | @${GO} test -mod=vendor -v -coverprofile ./tests/results/go-test-coverage.out -covermode count ./... 2>&1 | tee ./tests/results/go-test-results.out ;\ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 84 | RETURN=$$? ;\ |
| 85 | ${GO_JUNIT_REPORT} < ./tests/results/go-test-results.out > ./tests/results/go-test-results.xml ;\ |
| 86 | ${GOCOVER_COBERTURA} < ./tests/results/go-test-coverage.out > ./tests/results/go-test-coverage.xml ;\ |
| 87 | exit $$RETURN |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 88 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 89 | test-bbr: release-bbr docker-build # @HELP Validate that BBSim and BBR are working together |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 90 | DOCKER_RUN_ARGS="-pon 2 -onu 2" make docker-run |
Matteo Scandolo | 569e717 | 2019-12-20 11:51:51 -0800 | [diff] [blame] | 91 | sleep 5 |
Matteo Scandolo | c11074d | 2020-09-14 14:59:24 -0700 | [diff] [blame] | 92 | ./$(RELEASE_DIR)/$(RELEASE_BBR_NAME)-linux-amd64 -pon 2 -onu 2 -logfile tmp.logs |
Matteo Scandolo | 569e717 | 2019-12-20 11:51:51 -0800 | [diff] [blame] | 93 | docker rm -f bbsim |
| 94 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 95 | mod-update: # @HELP Download the dependencies to the vendor folder |
| 96 | ${GO} mod tidy |
| 97 | ${GO} mod vendor |
Matteo Scandolo | 3830549 | 2019-10-11 11:36:00 -0700 | [diff] [blame] | 98 | |
Matteo Scandolo | 4f4ac79 | 2020-10-01 16:33:21 -0700 | [diff] [blame] | 99 | docker-build: local-omci-sim local-protos# @HELP Build the BBSim docker container (contains BBSimCtl too) |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 100 | docker build \ |
| 101 | -t ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}bbsim:${DOCKER_TAG} \ |
| 102 | -f build/package/Dockerfile . |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 103 | |
Matteo Scandolo | 01d41ce | 2019-10-28 15:42:47 -0700 | [diff] [blame] | 104 | docker-push: # @HELP Push the docker container to a registry |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 105 | docker push ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}bbsim:${DOCKER_TAG} |
| 106 | |
Andrea Campanella | 64dffd5 | 2019-12-17 17:29:57 -0800 | [diff] [blame] | 107 | docker-kind-load: |
| 108 | @if [ "`kind get clusters | grep voltha-$(TYPE)`" = '' ]; then echo "no voltha-$(TYPE) cluster found" && exit 1; fi |
| 109 | kind load docker-image ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}bbsim:${DOCKER_TAG} --name=voltha-$(TYPE) --nodes $(shell kubectl get nodes --template='{{range .items}}{{.metadata.name}},{{end}}' | sed 's/,$$//') |
| 110 | |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 111 | docker-run: # @HELP Runs the container locally (available options: DOCKER_RUN_ARGS="-pon 2 -onu 2" make docker-run) |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 112 | docker run -d ${DOCKER_PORTS} --privileged --rm --name bbsim ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}bbsim:${DOCKER_TAG} /app/bbsim ${DOCKER_RUN_ARGS} |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 113 | |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 114 | docker-run-dev: # @HELP Runs the container locally (intended for development purposes, not in detached mode) |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 115 | docker run ${DOCKER_PORTS} --privileged --rm --name bbsim ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}bbsim:${DOCKER_TAG} /app/bbsim ${DOCKER_RUN_ARGS} |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 116 | |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 117 | .PHONY: docs docs-lint |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 118 | docs: swagger # @HELP Generate docs and opens them in the browser |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 119 | make -C docs html |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 120 | @echo -e "\nBBSim documentation generated in file://${PWD}/docs/build/html/index.html" |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 121 | |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 122 | docs-lint: |
| 123 | make -C docs lint |
| 124 | |
Matteo Scandolo | 8dea399 | 2019-10-22 10:54:25 -0700 | [diff] [blame] | 125 | # Release related items |
| 126 | # Generates binaries in $RELEASE_DIR with name $RELEASE_NAME-$RELEASE_OS_ARCH |
| 127 | # Inspired by: https://github.com/kubernetes/minikube/releases |
| 128 | RELEASE_DIR ?= release |
| 129 | RELEASE_OS_ARCH ?= linux-amd64 linux-arm64 windows-amd64 darwin-amd64 |
| 130 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 131 | RELEASE_BBR_NAME ?= bbr |
| 132 | RELEASE_BBSIM_NAME ?= bbsim |
| 133 | RELEASE_BBSIMCTL_NAME ?= bbsimctl |
Matteo Scandolo | 8dea399 | 2019-10-22 10:54:25 -0700 | [diff] [blame] | 134 | |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 135 | release-bbr: |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 136 | @echo "$(RELEASE_BBR_NAME)-linux-amd64" |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 137 | @${GO} build -mod vendor \ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 138 | -ldflags "-w -X main.buildTime=$(shell date +%Y/%m/%d-%H:%M:%S) \ |
| 139 | -X main.commitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 140 | -X main.gitStatus=${GIT_STATUS} \ |
| 141 | -X main.version=${VERSION}" \ |
| 142 | -o "$(RELEASE_DIR)/$(RELEASE_BBR_NAME)-linux-amd64" ./cmd/bbr |
Matteo Scandolo | 8dea399 | 2019-10-22 10:54:25 -0700 | [diff] [blame] | 143 | |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 144 | release-bbsim: |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 145 | @echo "$(RELEASE_BBSIM_NAME)-linux-amd64" |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 146 | @${GO} build -mod vendor \ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 147 | -ldflags "-w -X main.buildTime=$(shell date +%Y/%m/%d-%H:%M:%S) \ |
| 148 | -X main.commitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 149 | -X main.gitStatus=${GIT_STATUS} \ |
| 150 | -X main.version=${VERSION}" \ |
| 151 | -o "$(RELEASE_DIR)/$(RELEASE_BBSIM_NAME)-linux-amd64" ./cmd/bbsim |
Matteo Scandolo | 8dea399 | 2019-10-22 10:54:25 -0700 | [diff] [blame] | 152 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 153 | release-bbsimctl: |
| 154 | @${GO_SH} set -eo pipefail; \ |
| 155 | for os_arch in ${RELEASE_OS_ARCH}; do \ |
| 156 | echo "$(RELEASE_BBSIMCTL_NAME)-$$os_arch"; \ |
| 157 | GOOS="$${os_arch%-*}" GOARCH="$${os_arch#*-}" go build -mod vendor \ |
| 158 | -ldflags "-w -X github.com/opencord/bbsim/internal/bbsimctl/config.BuildTime=$(shell date +%Y/%m/%d-%H:%M:%S) \ |
| 159 | -X github.com/opencord/bbsim/internal/bbsimctl/config.CommitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 160 | -X github.com/opencord/bbsim/internal/bbsimctl/config.GitStatus=${GIT_STATUS} \ |
| 161 | -X github.com/opencord/bbsim/internal/bbsimctl/config.Version=${VERSION}" \ |
| 162 | -o "$(RELEASE_DIR)/$(RELEASE_BBSIMCTL_NAME)-$$os_arch" ./cmd/bbsimctl; \ |
| 163 | done' |
| 164 | |
| 165 | .PHONY: release release-bbr release-bbsim release-bbsimctl |
| 166 | release: release-bbr release-bbsim release-bbsimctl # @HELP Creates release ready bynaries for BBSimctl and BBR artifacts |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 167 | swagger: docs/swagger/bbsim/bbsim.swagger.json docs/swagger/leagacy/bbsim.swagger.json # @HELP Generate swagger documentation for BBSim API |
Matteo Scandolo | 8dea399 | 2019-10-22 10:54:25 -0700 | [diff] [blame] | 168 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 169 | help: # @HELP Print the command options |
| 170 | @echo |
| 171 | @echo "\033[0;31m BroadBand Simulator (BBSim) \033[0m" |
| 172 | @echo |
| 173 | @echo Emulates the control plane of an openolt compatible device |
| 174 | @echo Useful for development and scale testing |
| 175 | @echo |
| 176 | @grep -E '^.*: .* *# *@HELP' $(MAKEFILE_LIST) \ |
| 177 | | sort \ |
| 178 | | awk ' \ |
| 179 | BEGIN {FS = ": .* *# *@HELP"}; \ |
| 180 | {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}; \ |
| 181 | ' |
| 182 | |
Matteo Scandolo | ca08fc7 | 2019-12-04 14:17:39 -0800 | [diff] [blame] | 183 | ## Local Development Helpers |
| 184 | local-omci-sim: |
| 185 | ifdef LOCAL_OMCI_SIM |
| 186 | mkdir -p vendor/github.com/opencord/omci-sim/ |
| 187 | cp -r ${LOCAL_OMCI_SIM}/* vendor/github.com/opencord/omci-sim/ |
| 188 | endif |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 189 | |
Matteo Scandolo | 4f4ac79 | 2020-10-01 16:33:21 -0700 | [diff] [blame] | 190 | local-protos: ## Copies a local version of the voltha-protos dependency into the vendor directory |
| 191 | ifdef LOCAL_PROTOS |
| 192 | rm -rf vendor/github.com/opencord/voltha-protos/v4/go |
| 193 | mkdir -p vendor/github.com/opencord/voltha-protos/v4/go |
| 194 | cp -r ${LOCAL_PROTOS}/go/* vendor/github.com/opencord/voltha-protos/v4/go |
| 195 | rm -rf vendor/github.com/opencord/voltha-protos/v4/go/vendor |
| 196 | endif |
| 197 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 198 | # Internals |
Matteo Scandolo | 8dea399 | 2019-10-22 10:54:25 -0700 | [diff] [blame] | 199 | |
Matteo Scandolo | 3de9de0 | 2019-11-14 13:40:03 -0800 | [diff] [blame] | 200 | clean: |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 201 | @rm -f bbsim |
| 202 | @rm -f bbsimctl |
| 203 | @rm -f bbr |
| 204 | @rm -rf tools/bin |
| 205 | @rm -rf release/* |
Matteo Scandolo | 3de9de0 | 2019-11-14 13:40:03 -0800 | [diff] [blame] | 206 | |
Matteo Scandolo | 4f4ac79 | 2020-10-01 16:33:21 -0700 | [diff] [blame] | 207 | build-bbr: local-omci-sim local-protos |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 208 | @go build -mod vendor \ |
| 209 | -ldflags "-w -X main.buildTime=$(shell date +%Y/%m/%d-%H:%M:%S) \ |
| 210 | -X main.commitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 211 | -X main.gitStatus=${GIT_STATUS} \ |
| 212 | -X main.version=${VERSION}" \ |
| 213 | ./cmd/bbr |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 214 | |
Matteo Scandolo | 8df63df | 2019-09-12 10:34:32 -0700 | [diff] [blame] | 215 | build-bbsim: |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 216 | @go build -mod vendor \ |
| 217 | -ldflags "-w -X main.buildTime=$(shell date +%Y/%m/%d-%H:%M:%S) \ |
| 218 | -X main.commitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 219 | -X main.gitStatus=${GIT_STATUS} \ |
| 220 | -X main.version=${VERSION}" \ |
| 221 | ./cmd/bbsim |
Matteo Scandolo | 8df63df | 2019-09-12 10:34:32 -0700 | [diff] [blame] | 222 | |
| 223 | build-bbsimctl: |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 224 | @go build -mod vendor \ |
| 225 | -ldflags "-w -X github.com/opencord/bbsim/internal/bbsimctl/config.BuildTime=$(shell date +%Y/%m/%d-%H:%M:%S) \ |
| 226 | -X github.com/opencord/bbsim/internal/bbsimctl/config.CommitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 227 | -X github.com/opencord/bbsim/internal/bbsimctl/config.GitStatus=${GIT_STATUS} \ |
| 228 | -X github.com/opencord/bbsim/internal/bbsimctl/config.Version=${VERSION}" \ |
| 229 | ./cmd/bbsimctl |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 230 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 231 | setup_tools: |
| 232 | @echo "Downloading dependencies..." |
Matteo Scandolo | 4f4ac79 | 2020-10-01 16:33:21 -0700 | [diff] [blame] | 233 | @${GO} mod download github.com/grpc-ecosystem/grpc-gateway github.com/opencord/voltha-protos/v4 |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 234 | @echo "Dependencies downloaded OK" |
Matteo Scandolo | 84f7d48 | 2019-08-08 19:00:47 -0700 | [diff] [blame] | 235 | |
Matteo Scandolo | 4f4ac79 | 2020-10-01 16:33:21 -0700 | [diff] [blame] | 236 | VOLTHA_PROTOS ?= $(shell ${GO} list -f '{{ .Dir }}' -m github.com/opencord/voltha-protos/v4) |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 237 | GOOGLEAPI ?= $(shell ${GO} list -f '{{ .Dir }}' -m github.com/grpc-ecosystem/grpc-gateway) |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 238 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 239 | .PHONY: api/openolt/openolt.pb.go api/bbsim/bbsim.pb.go api/bbsim/bbsim.pb.gw.go api/legacy/bbsim.pb.go api/legacy/bbsim.pb.gw.go docs/swagger/bbsim/bbsim.swagger.json docs/swagger/leagacy/bbsim.swagger.json |
| 240 | api/openolt/openolt.pb.go: api/openolt/openolt.proto setup_tools |
| 241 | @echo $@ |
| 242 | @${PROTOC} -I. \ |
| 243 | -I${GOOGLEAPI}/third_party/googleapis \ |
| 244 | --go_out=plugins=grpc:./ \ |
| 245 | $< |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 246 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 247 | api/bbsim/bbsim.pb.go api/bbsim/bbsim.pb.gw.go: api/bbsim/bbsim.proto api/bbsim/bbsim.yaml setup_tools |
| 248 | @echo $@ |
| 249 | @${PROTOC} -I. \ |
| 250 | -I${GOOGLEAPI}/third_party/googleapis \ |
| 251 | -I${VOLTHA_PROTOS}/protos/ \ |
| 252 | --go_out=plugins=grpc:./ \ |
| 253 | --grpc-gateway_out=logtostderr=true,grpc_api_configuration=api/bbsim/bbsim.yaml,allow_delete_body=true:./ \ |
| 254 | $< |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 255 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 256 | api/legacy/bbsim.pb.go api/legacy/bbsim.pb.gw.go: api/legacy/bbsim.proto setup_tools |
| 257 | @echo $@ |
| 258 | @${PROTOC} -I. \ |
| 259 | -I${GOOGLEAPI}/third_party/googleapis/ \ |
| 260 | -I${GOOGLEAPI}/ \ |
| 261 | -I${VOLTHA_PROTOS}/protos/ \ |
| 262 | --go_out=plugins=grpc:./ \ |
| 263 | --grpc-gateway_out=logtostderr=true,allow_delete_body=true:./ \ |
| 264 | $< |
| 265 | |
| 266 | docs/swagger/bbsim/bbsim.swagger.json: api/bbsim/bbsim.yaml setup_tools |
| 267 | @echo $@ |
| 268 | @${PROTOC} -I ./api \ |
| 269 | -I${GOOGLEAPI}/ \ |
| 270 | -I${VOLTHA_PROTOS}/protos/ \ |
Zack Williams | d2907e6 | 2020-04-03 10:23:02 -0700 | [diff] [blame] | 271 | --swagger_out=logtostderr=true,allow_delete_body=true,disable_default_errors=true,grpc_api_configuration=$<:docs/swagger/ \ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 272 | api/bbsim/bbsim.proto |
| 273 | |
| 274 | docs/swagger/leagacy/bbsim.swagger.json: api/legacy/bbsim.proto setup_tools |
| 275 | @echo $@ |
| 276 | @${PROTOC} -I ./api \ |
| 277 | -I${GOOGLEAPI}/ \ |
| 278 | -I${VOLTHA_PROTOS}/protos/ \ |
Zack Williams | d2907e6 | 2020-04-03 10:23:02 -0700 | [diff] [blame] | 279 | --swagger_out=logtostderr=true,allow_delete_body=true,disable_default_errors=true:docs/swagger/ \ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 280 | $< |