Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | 14628cd | 2023-01-10 08:38:31 -0500 | [diff] [blame] | 3 | # Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 16 | # ----------------------------------------------------------------------- |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 17 | |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 18 | .DEFAULT_GOAL := help |
| 19 | MAKECMDGOALS ?= help |
| 20 | |
| 21 | TOP ?= . |
| 22 | MAKEDIR ?= $(TOP)/makefiles |
| 23 | |
| 24 | ##--------------------## |
| 25 | ##---] INCLUDES [---## |
| 26 | ##--------------------## |
| 27 | help-targets := help-all help HELP |
| 28 | $(if $(filter $(help-targets),$(MAKECMDGOALS))\ |
| 29 | ,$(eval include $(MAKEDIR)/help.mk)) |
| 30 | |
| 31 | ##-------------------## |
| 32 | ##---] GLOBALS [---## |
| 33 | ##-------------------## |
| 34 | SHELL = bash -e -o pipefail |
| 35 | VERSION ?= $(shell cat ./VERSION) |
Matteo Scandolo | 84f7d48 | 2019-08-08 19:00:47 -0700 | [diff] [blame] | 36 | DIFF ?= $(git diff --shortstat 2> /dev/null | tail -n1) |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 37 | GIT_STATUS ?= $(shell [ -z "$DIFF" ] && echo "Dirty" || echo "Clean") |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 38 | |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 39 | ## Docker related -- are these ${shell vars} or $(make macros) ? |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 40 | DOCKER_TAG ?= ${VERSION} |
Andrea Campanella | c5b106c | 2022-01-19 19:06:46 +0100 | [diff] [blame] | 41 | DOCKER_REPOSITORY ?= |
| 42 | DOCKER_REGISTRY ?= |
| 43 | DOCKER_RUN_ARGS ?= |
Andrea Campanella | d683d16 | 2020-10-13 16:40:27 +0200 | [diff] [blame] | 44 | 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] | 45 | TYPE ?= minimal |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 46 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 47 | # tool containers |
Matteo Scandolo | 34a9ea3 | 2020-11-19 17:40:49 -0800 | [diff] [blame] | 48 | VOLTHA_TOOLS_VERSION ?= 2.3.1 |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 49 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 50 | 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 |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 51 | 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 '# fix-editor-colorization-quote(') |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 52 | 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] | 53 | 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] | 54 | 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] | 55 | 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 |
| 56 | 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 |
| 57 | |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 58 | ## use local vars to shorten paths |
| 59 | bbsim-tag = ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}bbsim:${DOCKER_TAG} |
| 60 | |
Joey Armstrong | 5c61077 | 2023-01-23 16:03:32 -0500 | [diff] [blame] | 61 | ## ----------------------------------------------------------------------- |
| 62 | ## ----------------------------------------------------------------------- |
| 63 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 64 | # Public targets |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 65 | all: help |
| 66 | |
hkouser | 24361d4 | 2020-12-14 19:21:47 +0530 | [diff] [blame] | 67 | 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] | 68 | |
Matteo Scandolo | 6866b8c | 2019-10-28 16:15:24 -0700 | [diff] [blame] | 69 | .PHONY: build |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 70 | build: protos build-bbsim build-bbsimctl build-bbr |
| 71 | |
| 72 | ## lint and unit tests |
| 73 | |
| 74 | lint-dockerfile: |
| 75 | @echo "Running Dockerfile lint check..." |
| 76 | @${HADOLINT} $$(find ./build -name "Dockerfile*") |
| 77 | @echo "Dockerfile lint check OK" |
| 78 | |
| 79 | lint-mod: |
| 80 | @echo "Running dependency check..." |
| 81 | @${GO} mod verify |
| 82 | @echo "Dependency check OK. Running vendor check..." |
| 83 | @git status > /dev/null |
| 84 | @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) |
| 85 | @[[ `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) |
| 86 | ${GO} mod tidy |
| 87 | ${GO} mod vendor |
| 88 | @git status > /dev/null |
| 89 | @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) |
| 90 | @[[ `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) |
| 91 | @echo "Vendor check OK." |
| 92 | |
| 93 | lint: lint-mod lint-dockerfile |
| 94 | |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 95 | sca: |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 96 | @$(RM) -r ./sca-report |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 97 | @mkdir -p ./sca-report |
| 98 | @echo "Running static code analysis..." |
Matteo Scandolo | 96f8919 | 2021-03-12 13:17:26 -0800 | [diff] [blame] | 99 | @${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] | 100 | @echo "" |
| 101 | @echo "Static code analysis OK" |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 102 | |
Matteo Scandolo | 0e9fabf | 2020-09-30 17:19:27 -0700 | [diff] [blame] | 103 | test: docs-lint test-unit test-bbr |
Matteo Scandolo | 569e717 | 2019-12-20 11:51:51 -0800 | [diff] [blame] | 104 | |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 105 | test-unit: clean local-omci-lib-go # @HELP Execute unit tests |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 106 | @echo "Running unit tests..." |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 107 | @mkdir -p ./tests/results |
Matteo Scandolo | 4b077aa | 2021-02-16 17:33:37 -0800 | [diff] [blame] | 108 | @${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] | 109 | RETURN=$$? ;\ |
| 110 | ${GO_JUNIT_REPORT} < ./tests/results/go-test-results.out > ./tests/results/go-test-results.xml ;\ |
| 111 | ${GOCOVER_COBERTURA} < ./tests/results/go-test-coverage.out > ./tests/results/go-test-coverage.xml ;\ |
| 112 | exit $$RETURN |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 113 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 114 | test-bbr: release-bbr docker-build # @HELP Validate that BBSim and BBR are working together |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 115 | DOCKER_RUN_ARGS="-pon 2 -onu 2" $(MAKE) docker-run |
Matteo Scandolo | 569e717 | 2019-12-20 11:51:51 -0800 | [diff] [blame] | 116 | sleep 5 |
Matteo Scandolo | c11074d | 2020-09-14 14:59:24 -0700 | [diff] [blame] | 117 | ./$(RELEASE_DIR)/$(RELEASE_BBR_NAME)-linux-amd64 -pon 2 -onu 2 -logfile tmp.logs |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 118 | docker $(RM) -f bbsim |
Matteo Scandolo | 569e717 | 2019-12-20 11:51:51 -0800 | [diff] [blame] | 119 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 120 | mod-update: # @HELP Download the dependencies to the vendor folder |
| 121 | ${GO} mod tidy |
| 122 | ${GO} mod vendor |
Matteo Scandolo | 3830549 | 2019-10-11 11:36:00 -0700 | [diff] [blame] | 123 | |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 124 | 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] | 125 | docker build \ |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 126 | -t "$(bbsim-tag)" \ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 127 | -f build/package/Dockerfile . |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 128 | |
Matteo Scandolo | 01d41ce | 2019-10-28 15:42:47 -0700 | [diff] [blame] | 129 | docker-push: # @HELP Push the docker container to a registry |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 130 | docker push "$(bbsim-tag)" |
Andrea Campanella | 64dffd5 | 2019-12-17 17:29:57 -0800 | [diff] [blame] | 131 | docker-kind-load: |
| 132 | @if [ "`kind get clusters | grep voltha-$(TYPE)`" = '' ]; then echo "no voltha-$(TYPE) cluster found" && exit 1; fi |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 133 | kind load docker-image "$(bbsim-tag)" --name=voltha-$(TYPE) --nodes $(shell kubectl get nodes --template='{{range .items}}{{.metadata.name}},{{end}}' | sed 's/,$$//') |
| 134 | |
| 135 | ## ----------------------------------------------------------------------- |
| 136 | ## docker-run |
| 137 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 72558cb | 2022-11-30 06:35:52 -0500 | [diff] [blame] | 138 | |
| 139 | # % docker run --detach unless dev-mode |
| 140 | is-docker-run := $(filter-out %-dev,$(MAKECMDGOALS)) |
| 141 | is-docker-run := $(findstring docker-run,$(is-docker-run)) |
| 142 | |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 143 | docker-run-cmd = docker run |
Joey Armstrong | 72558cb | 2022-11-30 06:35:52 -0500 | [diff] [blame] | 144 | $(if $(is-docker-run),$(eval docker-run-cmd += --detach)) |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 145 | docker-run-cmd += ${DOCKER_PORTS} |
| 146 | docker-run-cmd += --privileged |
| 147 | docker-run-cmd += --rm |
| 148 | docker-run-cmd += --name bbsim |
| 149 | docker-run-cmd += "$(bbsim-tag)" /app/bbsim |
| 150 | docker-run-cmd += ${DOCKER_RUN_ARGS} |
Andrea Campanella | 64dffd5 | 2019-12-17 17:29:57 -0800 | [diff] [blame] | 151 | |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 152 | docker-run: # @HELP Runs the container locally (available options: DOCKER_RUN_ARGS="-pon 2 -onu 2" make docker-run) |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 153 | docker ps |
Joey Armstrong | 72558cb | 2022-11-30 06:35:52 -0500 | [diff] [blame] | 154 | $(docker-run-cmd) |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 155 | |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 156 | docker-run-dev: # @HELP Runs the container locally (intended for development purposes, not in detached mode) |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 157 | $(docker-run-cmd) |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 158 | |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 159 | ## ----------------------------------------------------------------------- |
| 160 | ## docker-run |
| 161 | ## ----------------------------------------------------------------------- |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 162 | .PHONY: docs docs-lint |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 163 | docs: swagger # @HELP Generate docs and opens them in the browser |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 164 | $(MAKE) -C docs html |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 165 | @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] | 166 | |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 167 | docs-lint: |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 168 | $(MAKE) -C docs lint |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 169 | |
Matteo Scandolo | 8dea399 | 2019-10-22 10:54:25 -0700 | [diff] [blame] | 170 | # Release related items |
| 171 | # Generates binaries in $RELEASE_DIR with name $RELEASE_NAME-$RELEASE_OS_ARCH |
| 172 | # Inspired by: https://github.com/kubernetes/minikube/releases |
| 173 | RELEASE_DIR ?= release |
| 174 | RELEASE_OS_ARCH ?= linux-amd64 linux-arm64 windows-amd64 darwin-amd64 |
| 175 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 176 | RELEASE_BBR_NAME ?= bbr |
| 177 | RELEASE_BBSIM_NAME ?= bbsim |
| 178 | RELEASE_BBSIMCTL_NAME ?= bbsimctl |
Matteo Scandolo | 8dea399 | 2019-10-22 10:54:25 -0700 | [diff] [blame] | 179 | |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 180 | release-bbr: |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 181 | @echo "$(RELEASE_BBR_NAME)-linux-amd64" |
Joey Armstrong | 787278a | 2022-11-30 09:30:22 -0500 | [diff] [blame] | 182 | ${GO} build -mod vendor \ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 183 | -ldflags "-w -X main.buildTime=$(shell date +%Y/%m/%d-%H:%M:%S) \ |
| 184 | -X main.commitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 185 | -X main.gitStatus=${GIT_STATUS} \ |
| 186 | -X main.version=${VERSION}" \ |
| 187 | -o "$(RELEASE_DIR)/$(RELEASE_BBR_NAME)-linux-amd64" ./cmd/bbr |
Matteo Scandolo | 8dea399 | 2019-10-22 10:54:25 -0700 | [diff] [blame] | 188 | |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 189 | release-bbsim: |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 190 | @echo "$(RELEASE_BBSIM_NAME)-linux-amd64" |
Joey Armstrong | 787278a | 2022-11-30 09:30:22 -0500 | [diff] [blame] | 191 | ${GO} build -mod vendor \ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 192 | -ldflags "-w -X main.buildTime=$(shell date +%Y/%m/%d-%H:%M:%S) \ |
| 193 | -X main.commitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 194 | -X main.gitStatus=${GIT_STATUS} \ |
| 195 | -X main.version=${VERSION}" \ |
| 196 | -o "$(RELEASE_DIR)/$(RELEASE_BBSIM_NAME)-linux-amd64" ./cmd/bbsim |
Matteo Scandolo | 8dea399 | 2019-10-22 10:54:25 -0700 | [diff] [blame] | 197 | |
Joey Armstrong | 5c61077 | 2023-01-23 16:03:32 -0500 | [diff] [blame] | 198 | release-bbsimctl: |
Joey Armstrong | 787278a | 2022-11-30 09:30:22 -0500 | [diff] [blame] | 199 | @echo "** $(MAKE): processing target [$@]" |
| 200 | ${GO_SH} set -eo pipefail; \ |
Joey Armstrong | 5c61077 | 2023-01-23 16:03:32 -0500 | [diff] [blame] | 201 | for os_arch in ${RELEASE_OS_ARCH}; do \ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 202 | echo "$(RELEASE_BBSIMCTL_NAME)-$$os_arch"; \ |
| 203 | GOOS="$${os_arch%-*}" GOARCH="$${os_arch#*-}" go build -mod vendor \ |
| 204 | -ldflags "-w -X github.com/opencord/bbsim/internal/bbsimctl/config.BuildTime=$(shell date +%Y/%m/%d-%H:%M:%S) \ |
| 205 | -X github.com/opencord/bbsim/internal/bbsimctl/config.CommitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 206 | -X github.com/opencord/bbsim/internal/bbsimctl/config.GitStatus=${GIT_STATUS} \ |
| 207 | -X github.com/opencord/bbsim/internal/bbsimctl/config.Version=${VERSION}" \ |
| 208 | -o "$(RELEASE_DIR)/$(RELEASE_BBSIMCTL_NAME)-$$os_arch" ./cmd/bbsimctl; \ |
Joey Armstrong | 787278a | 2022-11-30 09:30:22 -0500 | [diff] [blame] | 209 | done' |
| 210 | # fix-editor-colorization-quote(') |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 211 | |
Joey Armstrong | 5c61077 | 2023-01-23 16:03:32 -0500 | [diff] [blame] | 212 | ## ----------------------------------------------------------------------- |
| 213 | ## ----------------------------------------------------------------------- |
| 214 | release-deps += release-bbr |
| 215 | release-deps += release-bbsim |
| 216 | release-deps += release-bbsimctl |
| 217 | .PHONY: release $(release-deps) |
| 218 | release: release-init $(release-deps) # @HELP Creates release ready bynaries for BBSimctl and BBR artifacts |
Matteo Scandolo | 8dea399 | 2019-10-22 10:54:25 -0700 | [diff] [blame] | 219 | |
Joey Armstrong | 5c61077 | 2023-01-23 16:03:32 -0500 | [diff] [blame] | 220 | $(release-deps) : release-init |
| 221 | |
| 222 | release-init: |
| 223 | @echo "** $(MAKE): processing target [$@]" |
| 224 | ${GO_SH} set -eo pipefail\ |
Joey Armstrong | dd7a9aa | 2023-01-23 18:08:37 -0500 | [diff] [blame^] | 225 | ; echo "PWD: $$(/bin/pwd)"\ |
Joey Armstrong | 5c61077 | 2023-01-23 16:03:32 -0500 | [diff] [blame] | 226 | ; mkdir -p $(RELEASE_DIR)' |
| 227 | # fix-editor-colorization-quote(') |
| 228 | |
| 229 | ## ----------------------------------------------------------------------- |
| 230 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 231 | swagger-deps += docs/swagger/bbsim/bbsim.swagger.json |
| 232 | swagger-deps += docs/swagger/leagacy/bbsim.swagger.json |
| 233 | .PHONY: $(swagger-deps) |
| 234 | swagger: $(swagger-deps) # @HELP Generate swagger documentation for BBSim API |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 235 | |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 236 | ## ----------------------------------------------------------------------- |
Matteo Scandolo | ca08fc7 | 2019-12-04 14:17:39 -0800 | [diff] [blame] | 237 | ## Local Development Helpers |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 238 | ## ----------------------------------------------------------------------- |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 239 | local-omci-lib-go: |
| 240 | ifdef LOCAL_OMCI_LIB_GO |
| 241 | mkdir -p vendor/github.com/opencord/omci-lib-go |
| 242 | 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] | 243 | endif |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 244 | |
Matteo Scandolo | 4f4ac79 | 2020-10-01 16:33:21 -0700 | [diff] [blame] | 245 | local-protos: ## Copies a local version of the voltha-protos dependency into the vendor directory |
| 246 | ifdef LOCAL_PROTOS |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 247 | $(RM) -r vendor/github.com/opencord/voltha-protos/v5/go |
David K. Bainbridge | c415efe | 2021-08-19 13:05:21 +0000 | [diff] [blame] | 248 | mkdir -p vendor/github.com/opencord/voltha-protos/v5/go |
| 249 | cp -r ${LOCAL_PROTOS}/go/* vendor/github.com/opencord/voltha-protos/v5/go |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 250 | $(RM) -r vendor/github.com/opencord/voltha-protos/v5/go/vendor |
Matteo Scandolo | 4f4ac79 | 2020-10-01 16:33:21 -0700 | [diff] [blame] | 251 | endif |
| 252 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 253 | # Internals |
Matteo Scandolo | 8dea399 | 2019-10-22 10:54:25 -0700 | [diff] [blame] | 254 | |
Matteo Scandolo | 3de9de0 | 2019-11-14 13:40:03 -0800 | [diff] [blame] | 255 | clean: |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 256 | @$(RM) -f bbsim |
| 257 | @$(RM) -f bbsimctl |
| 258 | @$(RM) -f bbr |
| 259 | @$(RM) -r tools/bin |
| 260 | @$(RM) -r release/* |
Matteo Scandolo | 3de9de0 | 2019-11-14 13:40:03 -0800 | [diff] [blame] | 261 | |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 262 | build-bbr: local-omci-lib-go local-protos |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 263 | @go build -mod vendor \ |
| 264 | -ldflags "-w -X main.buildTime=$(shell date +%Y/%m/%d-%H:%M:%S) \ |
| 265 | -X main.commitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 266 | -X main.gitStatus=${GIT_STATUS} \ |
| 267 | -X main.version=${VERSION}" \ |
| 268 | ./cmd/bbr |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 269 | |
Matteo Scandolo | 8df63df | 2019-09-12 10:34:32 -0700 | [diff] [blame] | 270 | build-bbsim: |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 271 | @go build -mod vendor \ |
| 272 | -ldflags "-w -X main.buildTime=$(shell date +%Y/%m/%d-%H:%M:%S) \ |
| 273 | -X main.commitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 274 | -X main.gitStatus=${GIT_STATUS} \ |
| 275 | -X main.version=${VERSION}" \ |
| 276 | ./cmd/bbsim |
Matteo Scandolo | 8df63df | 2019-09-12 10:34:32 -0700 | [diff] [blame] | 277 | |
| 278 | build-bbsimctl: |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 279 | @go build -mod vendor \ |
| 280 | -ldflags "-w -X github.com/opencord/bbsim/internal/bbsimctl/config.BuildTime=$(shell date +%Y/%m/%d-%H:%M:%S) \ |
| 281 | -X github.com/opencord/bbsim/internal/bbsimctl/config.CommitHash=$(shell git log --pretty=format:%H -n 1) \ |
| 282 | -X github.com/opencord/bbsim/internal/bbsimctl/config.GitStatus=${GIT_STATUS} \ |
| 283 | -X github.com/opencord/bbsim/internal/bbsimctl/config.Version=${VERSION}" \ |
| 284 | ./cmd/bbsimctl |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 285 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 286 | setup_tools: |
| 287 | @echo "Downloading dependencies..." |
David K. Bainbridge | c415efe | 2021-08-19 13:05:21 +0000 | [diff] [blame] | 288 | @${GO} mod download github.com/grpc-ecosystem/grpc-gateway github.com/opencord/voltha-protos/v5 |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 289 | @echo "Dependencies downloaded OK" |
Matteo Scandolo | 84f7d48 | 2019-08-08 19:00:47 -0700 | [diff] [blame] | 290 | |
David K. Bainbridge | c415efe | 2021-08-19 13:05:21 +0000 | [diff] [blame] | 291 | VOLTHA_PROTOS ?= $(shell ${GO} list -f '{{ .Dir }}' -m github.com/opencord/voltha-protos/v5) |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 292 | 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] | 293 | |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 294 | .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 |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 295 | api/openolt/openolt.pb.go: api/openolt/openolt.proto setup_tools |
| 296 | @echo $@ |
| 297 | @${PROTOC} -I. \ |
| 298 | -I${GOOGLEAPI}/third_party/googleapis \ |
amit.ghosh | ee17c00 | 2021-06-10 12:14:38 +0200 | [diff] [blame] | 299 | --go_out=plugins=grpc:./ --go_opt=paths=source_relative \ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 300 | $< |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 301 | |
hkouser | 24361d4 | 2020-12-14 19:21:47 +0530 | [diff] [blame] | 302 | api/bbsim/bbsim_dmi.pb.go: api/bbsim/bbsim_dmi.proto setup_tools |
| 303 | @echo $@ |
| 304 | @${PROTOC} -I. \ |
| 305 | -I${GOOGLEAPI}/third_party/googleapis \ |
amit.ghosh | ee17c00 | 2021-06-10 12:14:38 +0200 | [diff] [blame] | 306 | --go_out=plugins=grpc:./ --go_opt=paths=source_relative \ |
hkouser | 24361d4 | 2020-12-14 19:21:47 +0530 | [diff] [blame] | 307 | $< |
| 308 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 309 | api/bbsim/bbsim.pb.go api/bbsim/bbsim.pb.gw.go: api/bbsim/bbsim.proto api/bbsim/bbsim.yaml setup_tools |
| 310 | @echo $@ |
| 311 | @${PROTOC} -I. \ |
| 312 | -I${GOOGLEAPI}/third_party/googleapis \ |
| 313 | -I${VOLTHA_PROTOS}/protos/ \ |
amit.ghosh | ee17c00 | 2021-06-10 12:14:38 +0200 | [diff] [blame] | 314 | --go_out=plugins=grpc:./ --go_opt=paths=source_relative \ |
| 315 | --grpc-gateway_out=logtostderr=true,paths=source_relative,grpc_api_configuration=api/bbsim/bbsim.yaml,allow_delete_body=true:./ \ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 316 | $< |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 317 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 318 | api/legacy/bbsim.pb.go api/legacy/bbsim.pb.gw.go: api/legacy/bbsim.proto setup_tools |
| 319 | @echo $@ |
| 320 | @${PROTOC} -I. \ |
| 321 | -I${GOOGLEAPI}/third_party/googleapis/ \ |
| 322 | -I${GOOGLEAPI}/ \ |
| 323 | -I${VOLTHA_PROTOS}/protos/ \ |
| 324 | --go_out=plugins=grpc:./ \ |
amit.ghosh | ee17c00 | 2021-06-10 12:14:38 +0200 | [diff] [blame] | 325 | --grpc-gateway_out=logtostderr=true,paths=source_relative,allow_delete_body=true:./ \ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 326 | $< |
| 327 | |
| 328 | docs/swagger/bbsim/bbsim.swagger.json: api/bbsim/bbsim.yaml setup_tools |
| 329 | @echo $@ |
| 330 | @${PROTOC} -I ./api \ |
| 331 | -I${GOOGLEAPI}/ \ |
| 332 | -I${VOLTHA_PROTOS}/protos/ \ |
Zack Williams | d2907e6 | 2020-04-03 10:23:02 -0700 | [diff] [blame] | 333 | --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] | 334 | api/bbsim/bbsim.proto |
| 335 | |
| 336 | docs/swagger/leagacy/bbsim.swagger.json: api/legacy/bbsim.proto setup_tools |
| 337 | @echo $@ |
| 338 | @${PROTOC} -I ./api \ |
| 339 | -I${GOOGLEAPI}/ \ |
| 340 | -I${VOLTHA_PROTOS}/protos/ \ |
Zack Williams | d2907e6 | 2020-04-03 10:23:02 -0700 | [diff] [blame] | 341 | --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] | 342 | $< |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 343 | |
| 344 | # [EOF] |