Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | bb1eabf | 2024-03-29 10:57:46 -0400 | [diff] [blame] | 3 | # Copyright 2017-2024 Open Networking Foundation 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 | # ----------------------------------------------------------------------- |
Joey Armstrong | bb1eabf | 2024-03-29 10:57:46 -0400 | [diff] [blame] | 17 | # SPDX-FileCopyrightText: 2017-2024 Open Networking Foundation Contributors |
| 18 | # SPDX-License-Identifier: Apache-2.0 |
| 19 | # ----------------------------------------------------------------------- |
| 20 | # Intent: This makefile will build, test & deploy tool bbsim |
| 21 | # ----------------------------------------------------------------------- |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 22 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 23 | $(if $(DEBUG),$(warning ENTER)) |
| 24 | |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 25 | .DEFAULT_GOAL := help |
| 26 | MAKECMDGOALS ?= help |
| 27 | |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 28 | ##-------------------## |
| 29 | ##---] GLOBALS [---## |
| 30 | ##-------------------## |
Joey Armstrong | 30bfd39 | 2024-04-10 16:10:06 -0400 | [diff] [blame^] | 31 | |
| 32 | # ----------------------------------------------------------------------- |
| 33 | # 2024-04-10 |
| 34 | # Usage: make USE_LF_MK=1 -or- USER is 'joey' |
| 35 | # ----------------------------------------------------------------------- |
| 36 | # This makefile flag/conditional is temporary: |
| 37 | # repo:onf-make is configured as a git submodule for the repository. |
| 38 | # Passing USE_LF_MK will enable on-demand library makefile use. |
| 39 | # Default makefile behavior is legacy, use repo:bbsim/makefiles/. |
| 40 | # ----------------------------------------------------------------------- |
| 41 | $(if $(findstring joey-disabled,$(USER)),\ |
| 42 | $(eval USE_LF_MK := 1)) # special snowflake |
| 43 | |
| 44 | ifdef USE_LF_MK |
Joey Armstrong | bb1eabf | 2024-03-29 10:57:46 -0400 | [diff] [blame] | 45 | |
| 46 | ##--------------------## |
| 47 | ##---] INCLUDES [---## |
| 48 | ##--------------------## |
| 49 | include lf/include.mk |
| 50 | include $(onf-mk-lib)/release/include.mk |
| 51 | |
| 52 | else |
| 53 | ##-------------------## |
| 54 | ##---] GLOBALS [---## |
| 55 | ##-------------------## |
Joey Armstrong | 30bfd39 | 2024-04-10 16:10:06 -0400 | [diff] [blame^] | 56 | TOP ?= $(strip \ |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 57 | $(dir \ |
| 58 | $(abspath $(lastword $(MAKEFILE_LIST)))\ |
| 59 | )\ |
| 60 | ) |
Joey Armstrong | 30bfd39 | 2024-04-10 16:10:06 -0400 | [diff] [blame^] | 61 | TOP := $(patsubst %/,%,$(TOP)) |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 62 | |
| 63 | ##--------------------## |
| 64 | ##---] INCLUDES [---## |
| 65 | ##--------------------## |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 66 | include $(TOP)/config.mk |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 67 | |
Joey Armstrong | 30bfd39 | 2024-04-10 16:10:06 -0400 | [diff] [blame^] | 68 | # export needed by docs/Makefile -> include makefiles/include. |
| 69 | export legacy-mk := $(TOP)/makefiles |
| 70 | include $(TOP)/makefiles/include.mk |
| 71 | |
| 72 | include $(legacy-mk)/release/include.mk |
Joey Armstrong | bb1eabf | 2024-03-29 10:57:46 -0400 | [diff] [blame] | 73 | endif # USER== |
| 74 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 75 | ##--------------------## |
| 76 | ##---] INCLUDES [---## |
| 77 | ##--------------------## |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 78 | help-targets := help-all help HELP |
| 79 | $(if $(filter $(help-targets),$(MAKECMDGOALS))\ |
Joey Armstrong | 30bfd39 | 2024-04-10 16:10:06 -0400 | [diff] [blame^] | 80 | ,$(eval include $(legacy-mk)/help.mk)) |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 81 | |
| 82 | ##-------------------## |
| 83 | ##---] GLOBALS [---## |
| 84 | ##-------------------## |
Joey Armstrong | 30bfd39 | 2024-04-10 16:10:06 -0400 | [diff] [blame^] | 85 | VERSION ?= $(shell cat ./VERSION) |
Matteo Scandolo | 84f7d48 | 2019-08-08 19:00:47 -0700 | [diff] [blame] | 86 | DIFF ?= $(git diff --shortstat 2> /dev/null | tail -n1) |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 87 | GIT_STATUS ?= $(shell [ -z "$DIFF" ] && echo "Dirty" || echo "Clean") |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 88 | |
Joey Armstrong | 30bfd39 | 2024-04-10 16:10:06 -0400 | [diff] [blame^] | 89 | include $(legacy-mk)/tools.mk # Command macros for DOCKER_*, GO_* |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 90 | |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 91 | ## use local vars to shorten paths |
| 92 | bbsim-tag = ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}bbsim:${DOCKER_TAG} |
| 93 | |
Joey Armstrong | 5c61077 | 2023-01-23 16:03:32 -0500 | [diff] [blame] | 94 | ## ----------------------------------------------------------------------- |
| 95 | ## ----------------------------------------------------------------------- |
| 96 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 97 | # Public targets |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 98 | all: help |
| 99 | |
hkouser | 24361d4 | 2020-12-14 19:21:47 +0530 | [diff] [blame] | 100 | 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] | 101 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 102 | ## ----------------------------------------------------------------------- |
| 103 | ## Intent: Build tools for use on localhost |
| 104 | ## ----------------------------------------------------------------------- |
| 105 | build-target-deps += build-bbsim |
| 106 | build-target-deps += build-bbsimctl |
| 107 | build-target-deps += build-bbr |
| 108 | |
Joey Armstrong | 30bfd39 | 2024-04-10 16:10:06 -0400 | [diff] [blame^] | 109 | # .PHONY: build |
| 110 | .PHONY: $(build-target-deps) |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 111 | build: protos $(build-target-deps) |
| 112 | |
| 113 | ## ----------------------------------------------------------------------- |
| 114 | ## Intent: Cross-compile binaries for release |
| 115 | ## ----------------------------------------------------------------------- |
| 116 | release-target-deps += release-bbr |
| 117 | release-target-deps += release-bbsim |
| 118 | release-target-deps += release-bbsimctl |
| 119 | |
| 120 | .PHONY: release $(release-target-deps) |
| 121 | release: $(release-target-deps) |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 122 | |
| 123 | ## lint and unit tests |
| 124 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 125 | ## ----------------------------------------------------------------------- |
| 126 | ## ----------------------------------------------------------------------- |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 127 | lint-dockerfile: |
| 128 | @echo "Running Dockerfile lint check..." |
| 129 | @${HADOLINT} $$(find ./build -name "Dockerfile*") |
| 130 | @echo "Dockerfile lint check OK" |
| 131 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 132 | ## ----------------------------------------------------------------------- |
| 133 | ## ----------------------------------------------------------------------- |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 134 | lint-mod: |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 135 | $(call banner-enter,Target $@) |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 136 | @echo "Running dependency check..." |
| 137 | @${GO} mod verify |
| 138 | @echo "Dependency check OK. Running vendor check..." |
| 139 | @git status > /dev/null |
| 140 | @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) |
| 141 | @[[ `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) |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 142 | |
| 143 | $(HIDE)$(MAKE) --no-print-directory mod-update |
| 144 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 145 | @git status > /dev/null |
| 146 | @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) |
| 147 | @[[ `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) |
| 148 | @echo "Vendor check OK." |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 149 | $(call banner-enter,Target $@) |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 150 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 151 | ## ----------------------------------------------------------------------- |
| 152 | ## ----------------------------------------------------------------------- |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 153 | lint: lint-mod lint-dockerfile |
| 154 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 155 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 156 | ## Intent: Generate a static code analysis report |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 157 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 158 | sca-report-dir := ./sca-report |
| 159 | sca-report-xml := $(sca-report-dir)/sca-report.xml |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame] | 160 | sca: |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 161 | $(call begin-enter,Target $@) |
| 162 | @$(RM) -r $(sca-report-dir) |
| 163 | @mkdir -p $(sca-report-dir) |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 164 | @echo "Running static code analysis..." |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 165 | @${GOLANGCI_LINT} run -vv --deadline=6m --out-format junit-xml ./... \ |
| 166 | | tee ./sca-report/sca-report.xml |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 167 | @echo "" |
| 168 | @echo "Static code analysis OK" |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 169 | $(call begin-leave,Target $@) |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 170 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 171 | ## ----------------------------------------------------------------------- |
| 172 | ## ----------------------------------------------------------------------- |
Matteo Scandolo | 0e9fabf | 2020-09-30 17:19:27 -0700 | [diff] [blame] | 173 | test: docs-lint test-unit test-bbr |
Matteo Scandolo | 569e717 | 2019-12-20 11:51:51 -0800 | [diff] [blame] | 174 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 175 | ## ----------------------------------------------------------------------- |
| 176 | ## ----------------------------------------------------------------------- |
Joey Armstrong | f99712c | 2023-06-01 17:04:38 -0400 | [diff] [blame] | 177 | coverage-out := ./tests/results/go-test-coverage.out |
| 178 | coverage-xml := ./tests/results/go-test-coverage.xml |
| 179 | |
| 180 | results-out := ./tests/results/go-test-results.out |
| 181 | results-xml := ./tests/results/go-test-results.xml |
| 182 | |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 183 | test-unit: clean local-omci-lib-go # @HELP Execute unit tests |
Joey Armstrong | 84b5bb9 | 2023-06-15 17:08:45 -0400 | [diff] [blame] | 184 | |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 185 | $(call banner-enter,Target $@) |
Joey Armstrong | 84b5bb9 | 2023-06-15 17:08:45 -0400 | [diff] [blame] | 186 | |
| 187 | @mkdir -p $(dir $(results-out)) |
Joey Armstrong | 84b5bb9 | 2023-06-15 17:08:45 -0400 | [diff] [blame] | 188 | |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 189 | $(call banner,Running unit tests...) |
| 190 | |
| 191 | $(if $(LOCAL_FIX_PERMS),\ |
| 192 | chmod o+w $(dir $(results-out) $(results-out))) |
Joey Armstrong | 84b5bb9 | 2023-06-15 17:08:45 -0400 | [diff] [blame] | 193 | set -euo pipefail \ |
| 194 | && ${GO} test -mod=vendor -bench=. -v \ |
Joey Armstrong | f99712c | 2023-06-01 17:04:38 -0400 | [diff] [blame] | 195 | -coverprofile $(coverage-out) \ |
| 196 | -covermode count ./... \ |
Joey Armstrong | 84b5bb9 | 2023-06-15 17:08:45 -0400 | [diff] [blame] | 197 | 2>&1 | tee "$(results-out)" |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 198 | $(if $(LOCAL_FIX_PERMS),\ |
| 199 | chmod o-w $(dir $(results-out) $(results-out))) |
Joey Armstrong | 84b5bb9 | 2023-06-15 17:08:45 -0400 | [diff] [blame] | 200 | |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 201 | $(call banner,Coverage report: junit) |
| 202 | $(if $(LOCAL_FIX_PERMS),\ |
| 203 | chmod o+w $(dir $(results-xml) $(results-xml))) |
Joey Armstrong | 84b5bb9 | 2023-06-15 17:08:45 -0400 | [diff] [blame] | 204 | ${GO_JUNIT_REPORT} < $(results-out) > $(results-xml) |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 205 | $(if $(LOCAL_FIX_PERMS),\ |
| 206 | chmod o-w $(dir $(results-xml) $(results-xml))) |
Joey Armstrong | 84b5bb9 | 2023-06-15 17:08:45 -0400 | [diff] [blame] | 207 | |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 208 | $(call banner,Coverage report: Cobertura) |
| 209 | $(if $(LOCAL_FIX_PERMS),\ |
| 210 | chmod o+w $(dir $(results-xml) $(coverage-xml))) |
Joey Armstrong | 84b5bb9 | 2023-06-15 17:08:45 -0400 | [diff] [blame] | 211 | ${GOCOVER_COBERTURA} < $(coverage-out) > $(coverage-xml) |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 212 | $(if $(LOCAL_FIX_PERMS),\ |
Joey Armstrong | 30bfd39 | 2024-04-10 16:10:06 -0400 | [diff] [blame^] | 213 | chmod o-w $(dir $(results-xml) $(coverage-xml))) |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 214 | |
| 215 | $(call banner,Coverage report directory perms:) |
Joey Armstrong | 84b5bb9 | 2023-06-15 17:08:45 -0400 | [diff] [blame] | 216 | |
| 217 | @echo |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 218 | @/bin/ls -ld tests tests/results |
Joey Armstrong | 84b5bb9 | 2023-06-15 17:08:45 -0400 | [diff] [blame] | 219 | |
| 220 | @echo |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 221 | @find $(dir $(results-out)) -print0 | xargs -0 ls -l |
| 222 | # chown -R $$(id -u):$$(id -g) $(dir $(results-xml) |
| 223 | |
| 224 | $(call banner,Locally modified files: git status) |
Joey Armstrong | 84b5bb9 | 2023-06-15 17:08:45 -0400 | [diff] [blame] | 225 | git status |
| 226 | |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 227 | $(call banner-leave,Target $@) |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 228 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 229 | ## ----------------------------------------------------------------------- |
| 230 | ## ----------------------------------------------------------------------- |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 231 | 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] | 232 | DOCKER_RUN_ARGS="-pon 2 -onu 2" $(MAKE) docker-run |
Matteo Scandolo | 569e717 | 2019-12-20 11:51:51 -0800 | [diff] [blame] | 233 | sleep 5 |
Matteo Scandolo | c11074d | 2020-09-14 14:59:24 -0700 | [diff] [blame] | 234 | ./$(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] | 235 | docker $(RM) -f bbsim |
Matteo Scandolo | 569e717 | 2019-12-20 11:51:51 -0800 | [diff] [blame] | 236 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 237 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 238 | ## ----------------------------------------------------------------------- |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 239 | 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] | 240 | docker build \ |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 241 | -t "$(bbsim-tag)" \ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 242 | -f build/package/Dockerfile . |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 243 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 244 | ## ----------------------------------------------------------------------- |
| 245 | ## ----------------------------------------------------------------------- |
Matteo Scandolo | 01d41ce | 2019-10-28 15:42:47 -0700 | [diff] [blame] | 246 | docker-push: # @HELP Push the docker container to a registry |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 247 | docker push "$(bbsim-tag)" |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 248 | |
| 249 | ## ----------------------------------------------------------------------- |
| 250 | ## ----------------------------------------------------------------------- |
Andrea Campanella | 64dffd5 | 2019-12-17 17:29:57 -0800 | [diff] [blame] | 251 | docker-kind-load: |
| 252 | @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] | 253 | kind load docker-image "$(bbsim-tag)" --name=voltha-$(TYPE) --nodes $(shell kubectl get nodes --template='{{range .items}}{{.metadata.name}},{{end}}' | sed 's/,$$//') |
| 254 | |
| 255 | ## ----------------------------------------------------------------------- |
| 256 | ## docker-run |
| 257 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 72558cb | 2022-11-30 06:35:52 -0500 | [diff] [blame] | 258 | |
| 259 | # % docker run --detach unless dev-mode |
| 260 | is-docker-run := $(filter-out %-dev,$(MAKECMDGOALS)) |
| 261 | is-docker-run := $(findstring docker-run,$(is-docker-run)) |
| 262 | |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 263 | docker-run-cmd = docker run |
Joey Armstrong | 72558cb | 2022-11-30 06:35:52 -0500 | [diff] [blame] | 264 | $(if $(is-docker-run),$(eval docker-run-cmd += --detach)) |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 265 | docker-run-cmd += ${DOCKER_PORTS} |
| 266 | docker-run-cmd += --privileged |
| 267 | docker-run-cmd += --rm |
| 268 | docker-run-cmd += --name bbsim |
| 269 | docker-run-cmd += "$(bbsim-tag)" /app/bbsim |
| 270 | docker-run-cmd += ${DOCKER_RUN_ARGS} |
Andrea Campanella | 64dffd5 | 2019-12-17 17:29:57 -0800 | [diff] [blame] | 271 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 272 | ## ----------------------------------------------------------------------- |
| 273 | ## ----------------------------------------------------------------------- |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 274 | 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] | 275 | docker ps |
Joey Armstrong | 72558cb | 2022-11-30 06:35:52 -0500 | [diff] [blame] | 276 | $(docker-run-cmd) |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 277 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 278 | ## ----------------------------------------------------------------------- |
| 279 | ## ----------------------------------------------------------------------- |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 280 | 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] | 281 | $(docker-run-cmd) |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 282 | |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 283 | ## ----------------------------------------------------------------------- |
| 284 | ## docker-run |
| 285 | ## ----------------------------------------------------------------------- |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 286 | .PHONY: docs docs-lint |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 287 | docs: swagger # @HELP Generate docs and opens them in the browser |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 288 | |
| 289 | $(call begin-enter,Target $@) |
| 290 | -$(MAKE) -C docs html |
| 291 | $(call begin-leave,Target $@) |
| 292 | |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 293 | @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] | 294 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 295 | ## ----------------------------------------------------------------------- |
| 296 | ## ----------------------------------------------------------------------- |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 297 | docs-lint: |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 298 | $(MAKE) -C docs lint-doc8 |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 299 | |
Joey Armstrong | 5c61077 | 2023-01-23 16:03:32 -0500 | [diff] [blame] | 300 | ## ----------------------------------------------------------------------- |
| 301 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 302 | swagger-deps += docs/swagger/bbsim/bbsim.swagger.json |
| 303 | swagger-deps += docs/swagger/leagacy/bbsim.swagger.json |
| 304 | .PHONY: $(swagger-deps) |
| 305 | swagger: $(swagger-deps) # @HELP Generate swagger documentation for BBSim API |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 306 | |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 307 | ## ----------------------------------------------------------------------- |
Matteo Scandolo | ca08fc7 | 2019-12-04 14:17:39 -0800 | [diff] [blame] | 308 | ## Local Development Helpers |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 309 | ## ----------------------------------------------------------------------- |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 310 | local-omci-lib-go: |
| 311 | ifdef LOCAL_OMCI_LIB_GO |
| 312 | mkdir -p vendor/github.com/opencord/omci-lib-go |
| 313 | 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] | 314 | endif |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 315 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 316 | ## ----------------------------------------------------------------------- |
| 317 | ## ----------------------------------------------------------------------- |
Matteo Scandolo | 4f4ac79 | 2020-10-01 16:33:21 -0700 | [diff] [blame] | 318 | local-protos: ## Copies a local version of the voltha-protos dependency into the vendor directory |
| 319 | ifdef LOCAL_PROTOS |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 320 | $(RM) -r vendor/github.com/opencord/voltha-protos/v5/go |
David K. Bainbridge | c415efe | 2021-08-19 13:05:21 +0000 | [diff] [blame] | 321 | mkdir -p vendor/github.com/opencord/voltha-protos/v5/go |
| 322 | 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] | 323 | $(RM) -r vendor/github.com/opencord/voltha-protos/v5/go/vendor |
Matteo Scandolo | 4f4ac79 | 2020-10-01 16:33:21 -0700 | [diff] [blame] | 324 | endif |
| 325 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 326 | ## ----------------------------------------------------------------------- |
| 327 | ## ----------------------------------------------------------------------- |
| 328 | clean :: |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 329 | @$(RM) -f bbsim |
| 330 | @$(RM) -f bbsimctl |
| 331 | @$(RM) -f bbr |
| 332 | @$(RM) -r tools/bin |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 333 | @$(RM) -r release |
Matteo Scandolo | 3de9de0 | 2019-11-14 13:40:03 -0800 | [diff] [blame] | 334 | |
Joey Armstrong | f99712c | 2023-06-01 17:04:38 -0400 | [diff] [blame] | 335 | @$(RM) $(coverage-out) |
| 336 | @$(RM) $(coverage-xml) |
| 337 | |
| 338 | @$(RM) $(results-out) |
| 339 | @$(RM) $(results-xml) |
| 340 | |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 341 | @$(RM) $(sca-report-xml) |
| 342 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 343 | sterile :: clean |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 344 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 345 | ## ----------------------------------------------------------------------- |
| 346 | ## ----------------------------------------------------------------------- |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 347 | setup_tools: |
| 348 | @echo "Downloading dependencies..." |
David K. Bainbridge | c415efe | 2021-08-19 13:05:21 +0000 | [diff] [blame] | 349 | @${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] | 350 | @echo "Dependencies downloaded OK" |
Matteo Scandolo | 84f7d48 | 2019-08-08 19:00:47 -0700 | [diff] [blame] | 351 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 352 | ## ----------------------------------------------------------------------- |
| 353 | ## ----------------------------------------------------------------------- |
David K. Bainbridge | c415efe | 2021-08-19 13:05:21 +0000 | [diff] [blame] | 354 | 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] | 355 | 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] | 356 | |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 357 | .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] | 358 | api/openolt/openolt.pb.go: api/openolt/openolt.proto setup_tools |
| 359 | @echo $@ |
| 360 | @${PROTOC} -I. \ |
| 361 | -I${GOOGLEAPI}/third_party/googleapis \ |
amit.ghosh | ee17c00 | 2021-06-10 12:14:38 +0200 | [diff] [blame] | 362 | --go_out=plugins=grpc:./ --go_opt=paths=source_relative \ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 363 | $< |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 364 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 365 | ## ----------------------------------------------------------------------- |
| 366 | ## ----------------------------------------------------------------------- |
hkouser | 24361d4 | 2020-12-14 19:21:47 +0530 | [diff] [blame] | 367 | api/bbsim/bbsim_dmi.pb.go: api/bbsim/bbsim_dmi.proto setup_tools |
| 368 | @echo $@ |
| 369 | @${PROTOC} -I. \ |
| 370 | -I${GOOGLEAPI}/third_party/googleapis \ |
amit.ghosh | ee17c00 | 2021-06-10 12:14:38 +0200 | [diff] [blame] | 371 | --go_out=plugins=grpc:./ --go_opt=paths=source_relative \ |
hkouser | 24361d4 | 2020-12-14 19:21:47 +0530 | [diff] [blame] | 372 | $< |
| 373 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 374 | ## ----------------------------------------------------------------------- |
| 375 | ## ----------------------------------------------------------------------- |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 376 | api/bbsim/bbsim.pb.go api/bbsim/bbsim.pb.gw.go: api/bbsim/bbsim.proto api/bbsim/bbsim.yaml setup_tools |
| 377 | @echo $@ |
| 378 | @${PROTOC} -I. \ |
| 379 | -I${GOOGLEAPI}/third_party/googleapis \ |
| 380 | -I${VOLTHA_PROTOS}/protos/ \ |
amit.ghosh | ee17c00 | 2021-06-10 12:14:38 +0200 | [diff] [blame] | 381 | --go_out=plugins=grpc:./ --go_opt=paths=source_relative \ |
| 382 | --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] | 383 | $< |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 384 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 385 | ## ----------------------------------------------------------------------- |
| 386 | ## ----------------------------------------------------------------------- |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 387 | api/legacy/bbsim.pb.go api/legacy/bbsim.pb.gw.go: api/legacy/bbsim.proto setup_tools |
| 388 | @echo $@ |
| 389 | @${PROTOC} -I. \ |
| 390 | -I${GOOGLEAPI}/third_party/googleapis/ \ |
| 391 | -I${GOOGLEAPI}/ \ |
| 392 | -I${VOLTHA_PROTOS}/protos/ \ |
| 393 | --go_out=plugins=grpc:./ \ |
amit.ghosh | ee17c00 | 2021-06-10 12:14:38 +0200 | [diff] [blame] | 394 | --grpc-gateway_out=logtostderr=true,paths=source_relative,allow_delete_body=true:./ \ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 395 | $< |
| 396 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 397 | ## ----------------------------------------------------------------------- |
| 398 | ## ----------------------------------------------------------------------- |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 399 | docs/swagger/bbsim/bbsim.swagger.json: api/bbsim/bbsim.yaml setup_tools |
| 400 | @echo $@ |
| 401 | @${PROTOC} -I ./api \ |
| 402 | -I${GOOGLEAPI}/ \ |
| 403 | -I${VOLTHA_PROTOS}/protos/ \ |
Zack Williams | d2907e6 | 2020-04-03 10:23:02 -0700 | [diff] [blame] | 404 | --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] | 405 | api/bbsim/bbsim.proto |
| 406 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 407 | ## ----------------------------------------------------------------------- |
| 408 | ## ----------------------------------------------------------------------- |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 409 | docs/swagger/leagacy/bbsim.swagger.json: api/legacy/bbsim.proto setup_tools |
| 410 | @echo $@ |
| 411 | @${PROTOC} -I ./api \ |
| 412 | -I${GOOGLEAPI}/ \ |
| 413 | -I${VOLTHA_PROTOS}/protos/ \ |
Zack Williams | d2907e6 | 2020-04-03 10:23:02 -0700 | [diff] [blame] | 414 | --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] | 415 | $< |
Joey Armstrong | 73d3579 | 2022-11-25 08:46:46 -0500 | [diff] [blame] | 416 | |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 417 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 96bcf1b | 2023-06-27 14:49:40 -0400 | [diff] [blame] | 418 | ## Intent: |
| 419 | ## ----------------------------------------------------------------------- |
| 420 | clean :: |
| 421 | $(RM) -r "docs/$(venv-name)" |
| 422 | |
| 423 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 424 | ## Intent: Helper target used to exercise release script changes |
| 425 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 30bfd39 | 2024-04-10 16:10:06 -0400 | [diff] [blame^] | 426 | # include $(MAKEDIR)/release/onf-publish.mk |
| 427 | include $(legacy-mk)/release/onf-publish.mk |
Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 428 | |
| 429 | $(if $(DEBUG),$(warning LEAVE)) |
| 430 | |
Joey Armstrong | 2c03936 | 2024-02-04 18:51:52 -0500 | [diff] [blame] | 431 | # [EOF] x 2 |