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