blob: ab0533b6d5b7635e2de45b0637e8942b62676c0f [file] [log] [blame]
Joey Armstrong73d35792022-11-25 08:46:46 -05001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrongbb1eabf2024-03-29 10:57:46 -04003# Copyright 2017-2024 Open Networking Foundation Contributors
Matteo Scandolo4747d292019-08-05 11:50:18 -07004#
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 Armstrong73d35792022-11-25 08:46:46 -050016# -----------------------------------------------------------------------
Joey Armstrongbb1eabf2024-03-29 10:57:46 -040017# 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 Scandolo4747d292019-08-05 11:50:18 -070022
Joey Armstrong36c9bcd2023-04-05 19:05:56 -040023$(if $(DEBUG),$(warning ENTER))
24
Joey Armstrong73d35792022-11-25 08:46:46 -050025.DEFAULT_GOAL := help
26MAKECMDGOALS ?= help
27
Joey Armstrong96bcf1b2023-06-27 14:49:40 -040028##-------------------##
29##---] GLOBALS [---##
30##-------------------##
Joey Armstrong30bfd392024-04-10 16:10:06 -040031
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
44ifdef USE_LF_MK
Joey Armstrongbb1eabf2024-03-29 10:57:46 -040045
46##--------------------##
47##---] INCLUDES [---##
48##--------------------##
49include lf/include.mk
50include $(onf-mk-lib)/release/include.mk
51
52else
53##-------------------##
54##---] GLOBALS [---##
55##-------------------##
Joey Armstrong30bfd392024-04-10 16:10:06 -040056TOP ?= $(strip \
Joey Armstrong96bcf1b2023-06-27 14:49:40 -040057 $(dir \
58 $(abspath $(lastword $(MAKEFILE_LIST)))\
59 )\
60)
Joey Armstrong30bfd392024-04-10 16:10:06 -040061TOP := $(patsubst %/,%,$(TOP))
Joey Armstrong73d35792022-11-25 08:46:46 -050062
63##--------------------##
64##---] INCLUDES [---##
65##--------------------##
Joey Armstrong96bcf1b2023-06-27 14:49:40 -040066include $(TOP)/config.mk
Joey Armstrong36c9bcd2023-04-05 19:05:56 -040067
Joey Armstrong30bfd392024-04-10 16:10:06 -040068# export needed by docs/Makefile -> include makefiles/include.
69export legacy-mk := $(TOP)/makefiles
70include $(TOP)/makefiles/include.mk
71
72include $(legacy-mk)/release/include.mk
Joey Armstrongbb1eabf2024-03-29 10:57:46 -040073endif # USER==
74
Joey Armstrong36c9bcd2023-04-05 19:05:56 -040075##--------------------##
76##---] INCLUDES [---##
77##--------------------##
Joey Armstrong73d35792022-11-25 08:46:46 -050078help-targets := help-all help HELP
79$(if $(filter $(help-targets),$(MAKECMDGOALS))\
Joey Armstrong30bfd392024-04-10 16:10:06 -040080 ,$(eval include $(legacy-mk)/help.mk))
Joey Armstrong73d35792022-11-25 08:46:46 -050081
82##-------------------##
83##---] GLOBALS [---##
84##-------------------##
Joey Armstrong30bfd392024-04-10 16:10:06 -040085VERSION ?= $(shell cat ./VERSION)
Matteo Scandolo84f7d482019-08-08 19:00:47 -070086DIFF ?= $(git diff --shortstat 2> /dev/null | tail -n1)
Zdravko Bozakov2da76342019-10-21 09:47:35 +020087GIT_STATUS ?= $(shell [ -z "$DIFF" ] && echo "Dirty" || echo "Clean")
Matteo Scandolo4747d292019-08-05 11:50:18 -070088
Joey Armstrong30bfd392024-04-10 16:10:06 -040089include $(legacy-mk)/tools.mk # Command macros for DOCKER_*, GO_*
Kent Hagerman60d62302020-03-10 17:02:36 -040090
Joey Armstrong73d35792022-11-25 08:46:46 -050091## use local vars to shorten paths
92bbsim-tag = ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}bbsim:${DOCKER_TAG}
93
Joey Armstrong5c610772023-01-23 16:03:32 -050094## -----------------------------------------------------------------------
95## -----------------------------------------------------------------------
96
Matteo Scandolo4747d292019-08-05 11:50:18 -070097# Public targets
Matteo Scandolo4747d292019-08-05 11:50:18 -070098all: help
99
hkouser24361d42020-12-14 19:21:47 +0530100protos: 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 Scandolo01d41ce2019-10-28 15:42:47 -0700101
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400102## -----------------------------------------------------------------------
103## Intent: Build tools for use on localhost
104## -----------------------------------------------------------------------
105build-target-deps += build-bbsim
106build-target-deps += build-bbsimctl
107build-target-deps += build-bbr
108
Joey Armstrong30bfd392024-04-10 16:10:06 -0400109# .PHONY: build
110.PHONY: $(build-target-deps)
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400111build: protos $(build-target-deps)
112
113## -----------------------------------------------------------------------
114## Intent: Cross-compile binaries for release
115## -----------------------------------------------------------------------
116release-target-deps += release-bbr
117release-target-deps += release-bbsim
118release-target-deps += release-bbsimctl
119
120.PHONY: release $(release-target-deps)
121release: $(release-target-deps)
Kent Hagerman60d62302020-03-10 17:02:36 -0400122
123## lint and unit tests
124
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400125## -----------------------------------------------------------------------
126## -----------------------------------------------------------------------
Kent Hagerman60d62302020-03-10 17:02:36 -0400127lint-dockerfile:
128 @echo "Running Dockerfile lint check..."
129 @${HADOLINT} $$(find ./build -name "Dockerfile*")
130 @echo "Dockerfile lint check OK"
131
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400132## -----------------------------------------------------------------------
133## -----------------------------------------------------------------------
Kent Hagerman60d62302020-03-10 17:02:36 -0400134lint-mod:
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400135 $(call banner-enter,Target $@)
Kent Hagerman60d62302020-03-10 17:02:36 -0400136 @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 Armstrong96bcf1b2023-06-27 14:49:40 -0400142
143 $(HIDE)$(MAKE) --no-print-directory mod-update
144
Kent Hagerman60d62302020-03-10 17:02:36 -0400145 @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 Armstrong96bcf1b2023-06-27 14:49:40 -0400149 $(call banner-enter,Target $@)
Kent Hagerman60d62302020-03-10 17:02:36 -0400150
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400151## -----------------------------------------------------------------------
152## -----------------------------------------------------------------------
Kent Hagerman60d62302020-03-10 17:02:36 -0400153lint: lint-mod lint-dockerfile
154
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400155## -----------------------------------------------------------------------
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400156## Intent: Generate a static code analysis report
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400157## -----------------------------------------------------------------------
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400158sca-report-dir := ./sca-report
159sca-report-xml := $(sca-report-dir)/sca-report.xml
Matteo Scandolo90d08f62020-10-29 12:06:55 -0700160sca:
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400161 $(call begin-enter,Target $@)
162 @$(RM) -r $(sca-report-dir)
163 @mkdir -p $(sca-report-dir)
Kent Hagerman60d62302020-03-10 17:02:36 -0400164 @echo "Running static code analysis..."
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400165 @${GOLANGCI_LINT} run -vv --deadline=6m --out-format junit-xml ./... \
166 | tee ./sca-report/sca-report.xml
Kent Hagerman60d62302020-03-10 17:02:36 -0400167 @echo ""
168 @echo "Static code analysis OK"
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400169 $(call begin-leave,Target $@)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700170
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400171## -----------------------------------------------------------------------
172## -----------------------------------------------------------------------
Matteo Scandolo0e9fabf2020-09-30 17:19:27 -0700173test: docs-lint test-unit test-bbr
Matteo Scandolo569e7172019-12-20 11:51:51 -0800174
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400175## -----------------------------------------------------------------------
176## -----------------------------------------------------------------------
Joey Armstrongf99712c2023-06-01 17:04:38 -0400177coverage-out := ./tests/results/go-test-coverage.out
178coverage-xml := ./tests/results/go-test-coverage.xml
179
180results-out := ./tests/results/go-test-results.out
181results-xml := ./tests/results/go-test-results.xml
182
Matteo Scandolocedde462021-03-09 17:37:16 -0800183test-unit: clean local-omci-lib-go # @HELP Execute unit tests
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400184
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400185 $(call banner-enter,Target $@)
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400186
187 @mkdir -p $(dir $(results-out))
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400188
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400189 $(call banner,Running unit tests...)
190
191 $(if $(LOCAL_FIX_PERMS),\
192 chmod o+w $(dir $(results-out) $(results-out)))
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400193 set -euo pipefail \
194 && ${GO} test -mod=vendor -bench=. -v \
Joey Armstrongf99712c2023-06-01 17:04:38 -0400195 -coverprofile $(coverage-out) \
196 -covermode count ./... \
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400197 2>&1 | tee "$(results-out)"
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400198 $(if $(LOCAL_FIX_PERMS),\
199 chmod o-w $(dir $(results-out) $(results-out)))
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400200
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400201 $(call banner,Coverage report: junit)
202 $(if $(LOCAL_FIX_PERMS),\
203 chmod o+w $(dir $(results-xml) $(results-xml)))
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400204 ${GO_JUNIT_REPORT} < $(results-out) > $(results-xml)
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400205 $(if $(LOCAL_FIX_PERMS),\
206 chmod o-w $(dir $(results-xml) $(results-xml)))
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400207
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400208 $(call banner,Coverage report: Cobertura)
209 $(if $(LOCAL_FIX_PERMS),\
210 chmod o+w $(dir $(results-xml) $(coverage-xml)))
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400211 ${GOCOVER_COBERTURA} < $(coverage-out) > $(coverage-xml)
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400212 $(if $(LOCAL_FIX_PERMS),\
Joey Armstrong30bfd392024-04-10 16:10:06 -0400213 chmod o-w $(dir $(results-xml) $(coverage-xml)))
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400214
215 $(call banner,Coverage report directory perms:)
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400216
217 @echo
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400218 @/bin/ls -ld tests tests/results
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400219
220 @echo
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400221 @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 Armstrong84b5bb92023-06-15 17:08:45 -0400225 git status
226
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400227 $(call banner-leave,Target $@)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700228
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400229## -----------------------------------------------------------------------
230## -----------------------------------------------------------------------
Kent Hagerman60d62302020-03-10 17:02:36 -0400231test-bbr: release-bbr docker-build # @HELP Validate that BBSim and BBR are working together
Joey Armstrong73d35792022-11-25 08:46:46 -0500232 DOCKER_RUN_ARGS="-pon 2 -onu 2" $(MAKE) docker-run
Matteo Scandolo569e7172019-12-20 11:51:51 -0800233 sleep 5
Matteo Scandoloc11074d2020-09-14 14:59:24 -0700234 ./$(RELEASE_DIR)/$(RELEASE_BBR_NAME)-linux-amd64 -pon 2 -onu 2 -logfile tmp.logs
Joey Armstrong73d35792022-11-25 08:46:46 -0500235 docker $(RM) -f bbsim
Matteo Scandolo569e7172019-12-20 11:51:51 -0800236
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400237## -----------------------------------------------------------------------
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400238## -----------------------------------------------------------------------
Matteo Scandolocedde462021-03-09 17:37:16 -0800239docker-build: local-omci-lib-go local-protos# @HELP Build the BBSim docker container (contains BBSimCtl too)
Kent Hagerman60d62302020-03-10 17:02:36 -0400240 docker build \
Joey Armstrong73d35792022-11-25 08:46:46 -0500241 -t "$(bbsim-tag)" \
Kent Hagerman60d62302020-03-10 17:02:36 -0400242 -f build/package/Dockerfile .
Matteo Scandolo4747d292019-08-05 11:50:18 -0700243
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400244## -----------------------------------------------------------------------
245## -----------------------------------------------------------------------
Matteo Scandolo01d41ce2019-10-28 15:42:47 -0700246docker-push: # @HELP Push the docker container to a registry
Joey Armstrong73d35792022-11-25 08:46:46 -0500247 docker push "$(bbsim-tag)"
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400248
249## -----------------------------------------------------------------------
250## -----------------------------------------------------------------------
Andrea Campanella64dffd52019-12-17 17:29:57 -0800251docker-kind-load:
252 @if [ "`kind get clusters | grep voltha-$(TYPE)`" = '' ]; then echo "no voltha-$(TYPE) cluster found" && exit 1; fi
Joey Armstrong73d35792022-11-25 08:46:46 -0500253 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 Armstrong72558cb2022-11-30 06:35:52 -0500258
259# % docker run --detach unless dev-mode
260is-docker-run := $(filter-out %-dev,$(MAKECMDGOALS))
261is-docker-run := $(findstring docker-run,$(is-docker-run))
262
Joey Armstrong73d35792022-11-25 08:46:46 -0500263docker-run-cmd = docker run
Joey Armstrong72558cb2022-11-30 06:35:52 -0500264$(if $(is-docker-run),$(eval docker-run-cmd += --detach))
Joey Armstrong73d35792022-11-25 08:46:46 -0500265docker-run-cmd += ${DOCKER_PORTS}
266docker-run-cmd += --privileged
267docker-run-cmd += --rm
268docker-run-cmd += --name bbsim
269docker-run-cmd += "$(bbsim-tag)" /app/bbsim
270docker-run-cmd += ${DOCKER_RUN_ARGS}
Andrea Campanella64dffd52019-12-17 17:29:57 -0800271
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400272## -----------------------------------------------------------------------
273## -----------------------------------------------------------------------
Matteo Scandoloe383d5d2019-10-25 14:47:27 -0700274docker-run: # @HELP Runs the container locally (available options: DOCKER_RUN_ARGS="-pon 2 -onu 2" make docker-run)
Joey Armstrong73d35792022-11-25 08:46:46 -0500275 docker ps
Joey Armstrong72558cb2022-11-30 06:35:52 -0500276 $(docker-run-cmd)
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700277
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400278## -----------------------------------------------------------------------
279## -----------------------------------------------------------------------
Matteo Scandoloe383d5d2019-10-25 14:47:27 -0700280docker-run-dev: # @HELP Runs the container locally (intended for development purposes, not in detached mode)
Joey Armstrong73d35792022-11-25 08:46:46 -0500281 $(docker-run-cmd)
Matteo Scandoloe383d5d2019-10-25 14:47:27 -0700282
Joey Armstrong73d35792022-11-25 08:46:46 -0500283## -----------------------------------------------------------------------
284## docker-run
285## -----------------------------------------------------------------------
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700286.PHONY: docs docs-lint
Zdravko Bozakov2da76342019-10-21 09:47:35 +0200287docs: swagger # @HELP Generate docs and opens them in the browser
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400288
289 $(call begin-enter,Target $@)
290 -$(MAKE) -C docs html
291 $(call begin-leave,Target $@)
292
Zdravko Bozakov2da76342019-10-21 09:47:35 +0200293 @echo -e "\nBBSim documentation generated in file://${PWD}/docs/build/html/index.html"
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700294
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400295## -----------------------------------------------------------------------
296## -----------------------------------------------------------------------
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700297docs-lint:
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400298 $(MAKE) -C docs lint-doc8
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700299
Joey Armstrong5c610772023-01-23 16:03:32 -0500300## -----------------------------------------------------------------------
301## -----------------------------------------------------------------------
Joey Armstrong73d35792022-11-25 08:46:46 -0500302swagger-deps += docs/swagger/bbsim/bbsim.swagger.json
303swagger-deps += docs/swagger/leagacy/bbsim.swagger.json
304.PHONY: $(swagger-deps)
305swagger: $(swagger-deps) # @HELP Generate swagger documentation for BBSim API
Matteo Scandolo4747d292019-08-05 11:50:18 -0700306
Joey Armstrong73d35792022-11-25 08:46:46 -0500307## -----------------------------------------------------------------------
Matteo Scandoloca08fc72019-12-04 14:17:39 -0800308## Local Development Helpers
Joey Armstrong73d35792022-11-25 08:46:46 -0500309## -----------------------------------------------------------------------
Matteo Scandolocedde462021-03-09 17:37:16 -0800310local-omci-lib-go:
311ifdef 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 Scandoloca08fc72019-12-04 14:17:39 -0800314endif
Matteo Scandolo4747d292019-08-05 11:50:18 -0700315
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400316## -----------------------------------------------------------------------
317## -----------------------------------------------------------------------
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700318local-protos: ## Copies a local version of the voltha-protos dependency into the vendor directory
319ifdef LOCAL_PROTOS
Joey Armstrong73d35792022-11-25 08:46:46 -0500320 $(RM) -r vendor/github.com/opencord/voltha-protos/v5/go
David K. Bainbridgec415efe2021-08-19 13:05:21 +0000321 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 Armstrong73d35792022-11-25 08:46:46 -0500323 $(RM) -r vendor/github.com/opencord/voltha-protos/v5/go/vendor
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700324endif
325
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400326## -----------------------------------------------------------------------
327## -----------------------------------------------------------------------
328clean ::
Joey Armstrong73d35792022-11-25 08:46:46 -0500329 @$(RM) -f bbsim
330 @$(RM) -f bbsimctl
331 @$(RM) -f bbr
332 @$(RM) -r tools/bin
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400333 @$(RM) -r release
Matteo Scandolo3de9de02019-11-14 13:40:03 -0800334
Joey Armstrongf99712c2023-06-01 17:04:38 -0400335 @$(RM) $(coverage-out)
336 @$(RM) $(coverage-xml)
337
338 @$(RM) $(results-out)
339 @$(RM) $(results-xml)
340
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400341 @$(RM) $(sca-report-xml)
342
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400343sterile :: clean
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700344
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400345## -----------------------------------------------------------------------
346## -----------------------------------------------------------------------
Kent Hagerman60d62302020-03-10 17:02:36 -0400347setup_tools:
348 @echo "Downloading dependencies..."
David K. Bainbridgec415efe2021-08-19 13:05:21 +0000349 @${GO} mod download github.com/grpc-ecosystem/grpc-gateway github.com/opencord/voltha-protos/v5
Kent Hagerman60d62302020-03-10 17:02:36 -0400350 @echo "Dependencies downloaded OK"
Matteo Scandolo84f7d482019-08-08 19:00:47 -0700351
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400352## -----------------------------------------------------------------------
353## -----------------------------------------------------------------------
David K. Bainbridgec415efe2021-08-19 13:05:21 +0000354VOLTHA_PROTOS ?= $(shell ${GO} list -f '{{ .Dir }}' -m github.com/opencord/voltha-protos/v5)
Kent Hagerman60d62302020-03-10 17:02:36 -0400355GOOGLEAPI ?= $(shell ${GO} list -f '{{ .Dir }}' -m github.com/grpc-ecosystem/grpc-gateway)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700356
Joey Armstrong73d35792022-11-25 08:46:46 -0500357.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 Hagerman60d62302020-03-10 17:02:36 -0400358api/openolt/openolt.pb.go: api/openolt/openolt.proto setup_tools
359 @echo $@
360 @${PROTOC} -I. \
361 -I${GOOGLEAPI}/third_party/googleapis \
amit.ghoshee17c002021-06-10 12:14:38 +0200362 --go_out=plugins=grpc:./ --go_opt=paths=source_relative \
Kent Hagerman60d62302020-03-10 17:02:36 -0400363 $<
Zdravko Bozakov2da76342019-10-21 09:47:35 +0200364
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400365## -----------------------------------------------------------------------
366## -----------------------------------------------------------------------
hkouser24361d42020-12-14 19:21:47 +0530367api/bbsim/bbsim_dmi.pb.go: api/bbsim/bbsim_dmi.proto setup_tools
368 @echo $@
369 @${PROTOC} -I. \
370 -I${GOOGLEAPI}/third_party/googleapis \
amit.ghoshee17c002021-06-10 12:14:38 +0200371 --go_out=plugins=grpc:./ --go_opt=paths=source_relative \
hkouser24361d42020-12-14 19:21:47 +0530372 $<
373
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400374## -----------------------------------------------------------------------
375## -----------------------------------------------------------------------
Kent Hagerman60d62302020-03-10 17:02:36 -0400376api/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.ghoshee17c002021-06-10 12:14:38 +0200381 --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 Hagerman60d62302020-03-10 17:02:36 -0400383 $<
Zdravko Bozakov2da76342019-10-21 09:47:35 +0200384
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400385## -----------------------------------------------------------------------
386## -----------------------------------------------------------------------
Kent Hagerman60d62302020-03-10 17:02:36 -0400387api/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.ghoshee17c002021-06-10 12:14:38 +0200394 --grpc-gateway_out=logtostderr=true,paths=source_relative,allow_delete_body=true:./ \
Kent Hagerman60d62302020-03-10 17:02:36 -0400395 $<
396
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400397## -----------------------------------------------------------------------
398## -----------------------------------------------------------------------
Kent Hagerman60d62302020-03-10 17:02:36 -0400399docs/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 Williamsd2907e62020-04-03 10:23:02 -0700404 --swagger_out=logtostderr=true,allow_delete_body=true,disable_default_errors=true,grpc_api_configuration=$<:docs/swagger/ \
Kent Hagerman60d62302020-03-10 17:02:36 -0400405 api/bbsim/bbsim.proto
406
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400407## -----------------------------------------------------------------------
408## -----------------------------------------------------------------------
Kent Hagerman60d62302020-03-10 17:02:36 -0400409docs/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 Williamsd2907e62020-04-03 10:23:02 -0700414 --swagger_out=logtostderr=true,allow_delete_body=true,disable_default_errors=true:docs/swagger/ \
Kent Hagerman60d62302020-03-10 17:02:36 -0400415 $<
Joey Armstrong73d35792022-11-25 08:46:46 -0500416
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400417## -----------------------------------------------------------------------
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400418## Intent:
419## -----------------------------------------------------------------------
420clean ::
421 $(RM) -r "docs/$(venv-name)"
422
423## -----------------------------------------------------------------------
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400424## Intent: Helper target used to exercise release script changes
425## -----------------------------------------------------------------------
Joey Armstrong30bfd392024-04-10 16:10:06 -0400426# include $(MAKEDIR)/release/onf-publish.mk
427include $(legacy-mk)/release/onf-publish.mk
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400428
429$(if $(DEBUG),$(warning LEAVE))
430
Joey Armstrong2c039362024-02-04 18:51:52 -0500431# [EOF] x 2