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 | |
hkouser | 24361d4 | 2020-12-14 19:21:47 +0530 | [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 api/bbsim/bbsim_dmi.pb.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 | 96f8919 | 2021-03-12 13:17:26 -0800 | [diff] [blame] | 74 | @${GOLANGCI_LINT} run -vv --deadline=6m --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 | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 80 | test-unit: clean local-omci-lib-go # @HELP Execute unit tests |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 81 | @echo "Running unit tests..." |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 82 | @mkdir -p ./tests/results |
Matteo Scandolo | 4b077aa | 2021-02-16 17:33:37 -0800 | [diff] [blame^] | 83 | @${GO} test -mod=vendor -bench=. -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 | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 99 | docker-build: local-omci-lib-go 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} |
Andrea Campanella | 64dffd5 | 2019-12-17 17:29:57 -0800 | [diff] [blame] | 106 | docker-kind-load: |
| 107 | @if [ "`kind get clusters | grep voltha-$(TYPE)`" = '' ]; then echo "no voltha-$(TYPE) cluster found" && exit 1; fi |
| 108 | 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/,$$//') |
| 109 | |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 110 | 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] | 111 | 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] | 112 | |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 113 | 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] | 114 | 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] | 115 | |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 116 | .PHONY: docs docs-lint |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 117 | docs: swagger # @HELP Generate docs and opens them in the browser |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 118 | make -C docs html |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 119 | @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] | 120 | |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 121 | docs-lint: |
| 122 | make -C docs lint |
| 123 | |
Matteo Scandolo | 8dea399 | 2019-10-22 10:54:25 -0700 | [diff] [blame] | 124 | # Release related items |
| 125 | # Generates binaries in $RELEASE_DIR with name $RELEASE_NAME-$RELEASE_OS_ARCH |
| 126 | # Inspired by: https://github.com/kubernetes/minikube/releases |
| 127 | RELEASE_DIR ?= release |
| 128 | RELEASE_OS_ARCH ?= linux-amd64 linux-arm64 windows-amd64 darwin-amd64 |
| 129 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 130 | RELEASE_BBR_NAME ?= bbr |
| 131 | RELEASE_BBSIM_NAME ?= bbsim |
| 132 | RELEASE_BBSIMCTL_NAME ?= bbsimctl |
Matteo Scandolo | 8dea399 | 2019-10-22 10:54:25 -0700 | [diff] [blame] | 133 | |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 134 | release-bbr: |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 135 | @echo "$(RELEASE_BBR_NAME)-linux-amd64" |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 136 | @${GO} build -mod vendor \ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 137 | -ldflags "-w -X main.buildTime=$(shell date +%Y/%m/%d-%H:%M:%S) \ |
| 138 | -X main.commitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 139 | -X main.gitStatus=${GIT_STATUS} \ |
| 140 | -X main.version=${VERSION}" \ |
| 141 | -o "$(RELEASE_DIR)/$(RELEASE_BBR_NAME)-linux-amd64" ./cmd/bbr |
Matteo Scandolo | 8dea399 | 2019-10-22 10:54:25 -0700 | [diff] [blame] | 142 | |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 143 | release-bbsim: |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 144 | @echo "$(RELEASE_BBSIM_NAME)-linux-amd64" |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 145 | @${GO} build -mod vendor \ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 146 | -ldflags "-w -X main.buildTime=$(shell date +%Y/%m/%d-%H:%M:%S) \ |
| 147 | -X main.commitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 148 | -X main.gitStatus=${GIT_STATUS} \ |
| 149 | -X main.version=${VERSION}" \ |
| 150 | -o "$(RELEASE_DIR)/$(RELEASE_BBSIM_NAME)-linux-amd64" ./cmd/bbsim |
Matteo Scandolo | 8dea399 | 2019-10-22 10:54:25 -0700 | [diff] [blame] | 151 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 152 | release-bbsimctl: |
| 153 | @${GO_SH} set -eo pipefail; \ |
| 154 | for os_arch in ${RELEASE_OS_ARCH}; do \ |
| 155 | echo "$(RELEASE_BBSIMCTL_NAME)-$$os_arch"; \ |
| 156 | GOOS="$${os_arch%-*}" GOARCH="$${os_arch#*-}" go build -mod vendor \ |
| 157 | -ldflags "-w -X github.com/opencord/bbsim/internal/bbsimctl/config.BuildTime=$(shell date +%Y/%m/%d-%H:%M:%S) \ |
| 158 | -X github.com/opencord/bbsim/internal/bbsimctl/config.CommitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 159 | -X github.com/opencord/bbsim/internal/bbsimctl/config.GitStatus=${GIT_STATUS} \ |
| 160 | -X github.com/opencord/bbsim/internal/bbsimctl/config.Version=${VERSION}" \ |
| 161 | -o "$(RELEASE_DIR)/$(RELEASE_BBSIMCTL_NAME)-$$os_arch" ./cmd/bbsimctl; \ |
| 162 | done' |
| 163 | |
| 164 | .PHONY: release release-bbr release-bbsim release-bbsimctl |
| 165 | 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] | 166 | 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] | 167 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 168 | help: # @HELP Print the command options |
| 169 | @echo |
| 170 | @echo "\033[0;31m BroadBand Simulator (BBSim) \033[0m" |
| 171 | @echo |
| 172 | @echo Emulates the control plane of an openolt compatible device |
| 173 | @echo Useful for development and scale testing |
| 174 | @echo |
| 175 | @grep -E '^.*: .* *# *@HELP' $(MAKEFILE_LIST) \ |
| 176 | | sort \ |
| 177 | | awk ' \ |
| 178 | BEGIN {FS = ": .* *# *@HELP"}; \ |
| 179 | {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}; \ |
| 180 | ' |
| 181 | |
Matteo Scandolo | ca08fc7 | 2019-12-04 14:17:39 -0800 | [diff] [blame] | 182 | ## Local Development Helpers |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 183 | local-omci-lib-go: |
| 184 | ifdef LOCAL_OMCI_LIB_GO |
| 185 | mkdir -p vendor/github.com/opencord/omci-lib-go |
| 186 | cp -r ${LOCAL_OMCI_LIB_GO}/* vendor/github.com/opencord/omci-lib-go |
Matteo Scandolo | ca08fc7 | 2019-12-04 14:17:39 -0800 | [diff] [blame] | 187 | endif |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 188 | |
Matteo Scandolo | 4f4ac79 | 2020-10-01 16:33:21 -0700 | [diff] [blame] | 189 | local-protos: ## Copies a local version of the voltha-protos dependency into the vendor directory |
| 190 | ifdef LOCAL_PROTOS |
| 191 | rm -rf vendor/github.com/opencord/voltha-protos/v4/go |
| 192 | mkdir -p vendor/github.com/opencord/voltha-protos/v4/go |
| 193 | cp -r ${LOCAL_PROTOS}/go/* vendor/github.com/opencord/voltha-protos/v4/go |
| 194 | rm -rf vendor/github.com/opencord/voltha-protos/v4/go/vendor |
| 195 | endif |
| 196 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 197 | # Internals |
Matteo Scandolo | 8dea399 | 2019-10-22 10:54:25 -0700 | [diff] [blame] | 198 | |
Matteo Scandolo | 3de9de0 | 2019-11-14 13:40:03 -0800 | [diff] [blame] | 199 | clean: |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 200 | @rm -f bbsim |
| 201 | @rm -f bbsimctl |
| 202 | @rm -f bbr |
| 203 | @rm -rf tools/bin |
| 204 | @rm -rf release/* |
Matteo Scandolo | 3de9de0 | 2019-11-14 13:40:03 -0800 | [diff] [blame] | 205 | |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 206 | build-bbr: local-omci-lib-go local-protos |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 207 | @go build -mod vendor \ |
| 208 | -ldflags "-w -X main.buildTime=$(shell date +%Y/%m/%d-%H:%M:%S) \ |
| 209 | -X main.commitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 210 | -X main.gitStatus=${GIT_STATUS} \ |
| 211 | -X main.version=${VERSION}" \ |
| 212 | ./cmd/bbr |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 213 | |
Matteo Scandolo | 8df63df | 2019-09-12 10:34:32 -0700 | [diff] [blame] | 214 | build-bbsim: |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 215 | @go build -mod vendor \ |
| 216 | -ldflags "-w -X main.buildTime=$(shell date +%Y/%m/%d-%H:%M:%S) \ |
| 217 | -X main.commitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 218 | -X main.gitStatus=${GIT_STATUS} \ |
| 219 | -X main.version=${VERSION}" \ |
| 220 | ./cmd/bbsim |
Matteo Scandolo | 8df63df | 2019-09-12 10:34:32 -0700 | [diff] [blame] | 221 | |
| 222 | build-bbsimctl: |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 223 | @go build -mod vendor \ |
| 224 | -ldflags "-w -X github.com/opencord/bbsim/internal/bbsimctl/config.BuildTime=$(shell date +%Y/%m/%d-%H:%M:%S) \ |
| 225 | -X github.com/opencord/bbsim/internal/bbsimctl/config.CommitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 226 | -X github.com/opencord/bbsim/internal/bbsimctl/config.GitStatus=${GIT_STATUS} \ |
| 227 | -X github.com/opencord/bbsim/internal/bbsimctl/config.Version=${VERSION}" \ |
| 228 | ./cmd/bbsimctl |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 229 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 230 | setup_tools: |
| 231 | @echo "Downloading dependencies..." |
Matteo Scandolo | 4f4ac79 | 2020-10-01 16:33:21 -0700 | [diff] [blame] | 232 | @${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] | 233 | @echo "Dependencies downloaded OK" |
Matteo Scandolo | 84f7d48 | 2019-08-08 19:00:47 -0700 | [diff] [blame] | 234 | |
Matteo Scandolo | 4f4ac79 | 2020-10-01 16:33:21 -0700 | [diff] [blame] | 235 | 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] | 236 | 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] | 237 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 238 | .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 |
| 239 | api/openolt/openolt.pb.go: api/openolt/openolt.proto setup_tools |
| 240 | @echo $@ |
| 241 | @${PROTOC} -I. \ |
| 242 | -I${GOOGLEAPI}/third_party/googleapis \ |
| 243 | --go_out=plugins=grpc:./ \ |
| 244 | $< |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 245 | |
hkouser | 24361d4 | 2020-12-14 19:21:47 +0530 | [diff] [blame] | 246 | api/bbsim/bbsim_dmi.pb.go: api/bbsim/bbsim_dmi.proto setup_tools |
| 247 | @echo $@ |
| 248 | @${PROTOC} -I. \ |
| 249 | -I${GOOGLEAPI}/third_party/googleapis \ |
| 250 | --go_out=plugins=grpc:./ \ |
| 251 | $< |
| 252 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 253 | api/bbsim/bbsim.pb.go api/bbsim/bbsim.pb.gw.go: api/bbsim/bbsim.proto api/bbsim/bbsim.yaml setup_tools |
| 254 | @echo $@ |
| 255 | @${PROTOC} -I. \ |
| 256 | -I${GOOGLEAPI}/third_party/googleapis \ |
| 257 | -I${VOLTHA_PROTOS}/protos/ \ |
| 258 | --go_out=plugins=grpc:./ \ |
| 259 | --grpc-gateway_out=logtostderr=true,grpc_api_configuration=api/bbsim/bbsim.yaml,allow_delete_body=true:./ \ |
| 260 | $< |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 261 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 262 | api/legacy/bbsim.pb.go api/legacy/bbsim.pb.gw.go: api/legacy/bbsim.proto setup_tools |
| 263 | @echo $@ |
| 264 | @${PROTOC} -I. \ |
| 265 | -I${GOOGLEAPI}/third_party/googleapis/ \ |
| 266 | -I${GOOGLEAPI}/ \ |
| 267 | -I${VOLTHA_PROTOS}/protos/ \ |
| 268 | --go_out=plugins=grpc:./ \ |
| 269 | --grpc-gateway_out=logtostderr=true,allow_delete_body=true:./ \ |
| 270 | $< |
| 271 | |
| 272 | docs/swagger/bbsim/bbsim.swagger.json: api/bbsim/bbsim.yaml setup_tools |
| 273 | @echo $@ |
| 274 | @${PROTOC} -I ./api \ |
| 275 | -I${GOOGLEAPI}/ \ |
| 276 | -I${VOLTHA_PROTOS}/protos/ \ |
Zack Williams | d2907e6 | 2020-04-03 10:23:02 -0700 | [diff] [blame] | 277 | --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] | 278 | api/bbsim/bbsim.proto |
| 279 | |
| 280 | docs/swagger/leagacy/bbsim.swagger.json: api/legacy/bbsim.proto setup_tools |
| 281 | @echo $@ |
| 282 | @${PROTOC} -I ./api \ |
| 283 | -I${GOOGLEAPI}/ \ |
| 284 | -I${VOLTHA_PROTOS}/protos/ \ |
Zack Williams | d2907e6 | 2020-04-03 10:23:02 -0700 | [diff] [blame] | 285 | --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] | 286 | $< |