blob: 5829b5db5e6b4f844ef6d6fe82ffe1c9202b0de7 [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 Armstrongbb1eabf2024-03-29 10:57:46 -040031ifeq ($(USER),joey-disable) # temporary for transition
32
33##--------------------##
34##---] INCLUDES [---##
35##--------------------##
36include lf/include.mk
37include $(onf-mk-lib)/release/include.mk
38
39else
40##-------------------##
41##---] GLOBALS [---##
42##-------------------##
Joey Armstrong96bcf1b2023-06-27 14:49:40 -040043TOP ?=$(strip \
44 $(dir \
45 $(abspath $(lastword $(MAKEFILE_LIST)))\
46 )\
47)
Joey Armstrong73d35792022-11-25 08:46:46 -050048
49##--------------------##
50##---] INCLUDES [---##
51##--------------------##
Joey Armstrong96bcf1b2023-06-27 14:49:40 -040052include $(TOP)/config.mk
53include $(TOP)/makefiles/include.mk
54include $(ONF_MAKEDIR)/release/include.mk
Joey Armstrong36c9bcd2023-04-05 19:05:56 -040055
Joey Armstrongbb1eabf2024-03-29 10:57:46 -040056endif # USER==
57
Joey Armstrong36c9bcd2023-04-05 19:05:56 -040058##--------------------##
59##---] INCLUDES [---##
60##--------------------##
Joey Armstrong73d35792022-11-25 08:46:46 -050061help-targets := help-all help HELP
62$(if $(filter $(help-targets),$(MAKECMDGOALS))\
63 ,$(eval include $(MAKEDIR)/help.mk))
64
65##-------------------##
66##---] GLOBALS [---##
67##-------------------##
Joey Armstrong73d35792022-11-25 08:46:46 -050068VERSION ?= $(shell cat ./VERSION)
Matteo Scandolo84f7d482019-08-08 19:00:47 -070069DIFF ?= $(git diff --shortstat 2> /dev/null | tail -n1)
Zdravko Bozakov2da76342019-10-21 09:47:35 +020070GIT_STATUS ?= $(shell [ -z "$DIFF" ] && echo "Dirty" || echo "Clean")
Matteo Scandolo4747d292019-08-05 11:50:18 -070071
Joey Armstrong36c9bcd2023-04-05 19:05:56 -040072include $(MAKEDIR)/tools.mk # Command macros for DOCKER_*, GO_*
Kent Hagerman60d62302020-03-10 17:02:36 -040073
Joey Armstrong73d35792022-11-25 08:46:46 -050074## use local vars to shorten paths
75bbsim-tag = ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}bbsim:${DOCKER_TAG}
76
Joey Armstrong5c610772023-01-23 16:03:32 -050077## -----------------------------------------------------------------------
78## -----------------------------------------------------------------------
79
Matteo Scandolo4747d292019-08-05 11:50:18 -070080# Public targets
Matteo Scandolo4747d292019-08-05 11:50:18 -070081all: help
82
hkouser24361d42020-12-14 19:21:47 +053083protos: 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 -070084
Joey Armstrong36c9bcd2023-04-05 19:05:56 -040085## -----------------------------------------------------------------------
86## Intent: Build tools for use on localhost
87## -----------------------------------------------------------------------
88build-target-deps += build-bbsim
89build-target-deps += build-bbsimctl
90build-target-deps += build-bbr
91
92.PHONY: build $(build-target-deps)
93build: protos $(build-target-deps)
94
95## -----------------------------------------------------------------------
96## Intent: Cross-compile binaries for release
97## -----------------------------------------------------------------------
98release-target-deps += release-bbr
99release-target-deps += release-bbsim
100release-target-deps += release-bbsimctl
101
102.PHONY: release $(release-target-deps)
103release: $(release-target-deps)
Kent Hagerman60d62302020-03-10 17:02:36 -0400104
105## lint and unit tests
106
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400107## -----------------------------------------------------------------------
108## -----------------------------------------------------------------------
Kent Hagerman60d62302020-03-10 17:02:36 -0400109lint-dockerfile:
110 @echo "Running Dockerfile lint check..."
111 @${HADOLINT} $$(find ./build -name "Dockerfile*")
112 @echo "Dockerfile lint check OK"
113
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400114## -----------------------------------------------------------------------
115## -----------------------------------------------------------------------
Kent Hagerman60d62302020-03-10 17:02:36 -0400116lint-mod:
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400117 $(call banner-enter,Target $@)
Kent Hagerman60d62302020-03-10 17:02:36 -0400118 @echo "Running dependency check..."
119 @${GO} mod verify
120 @echo "Dependency check OK. Running vendor check..."
121 @git status > /dev/null
122 @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)
123 @[[ `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 -0400124
125 $(HIDE)$(MAKE) --no-print-directory mod-update
126
Kent Hagerman60d62302020-03-10 17:02:36 -0400127 @git status > /dev/null
128 @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)
129 @[[ `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)
130 @echo "Vendor check OK."
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400131 $(call banner-enter,Target $@)
Kent Hagerman60d62302020-03-10 17:02:36 -0400132
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400133## -----------------------------------------------------------------------
134## -----------------------------------------------------------------------
Kent Hagerman60d62302020-03-10 17:02:36 -0400135lint: lint-mod lint-dockerfile
136
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400137## -----------------------------------------------------------------------
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400138## Intent: Generate a static code analysis report
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400139## -----------------------------------------------------------------------
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400140sca-report-dir := ./sca-report
141sca-report-xml := $(sca-report-dir)/sca-report.xml
Matteo Scandolo90d08f62020-10-29 12:06:55 -0700142sca:
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400143 $(call begin-enter,Target $@)
144 @$(RM) -r $(sca-report-dir)
145 @mkdir -p $(sca-report-dir)
Kent Hagerman60d62302020-03-10 17:02:36 -0400146 @echo "Running static code analysis..."
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400147 @${GOLANGCI_LINT} run -vv --deadline=6m --out-format junit-xml ./... \
148 | tee ./sca-report/sca-report.xml
Kent Hagerman60d62302020-03-10 17:02:36 -0400149 @echo ""
150 @echo "Static code analysis OK"
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400151 $(call begin-leave,Target $@)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700152
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400153## -----------------------------------------------------------------------
154## -----------------------------------------------------------------------
Matteo Scandolo0e9fabf2020-09-30 17:19:27 -0700155test: docs-lint test-unit test-bbr
Matteo Scandolo569e7172019-12-20 11:51:51 -0800156
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400157## -----------------------------------------------------------------------
158## -----------------------------------------------------------------------
Joey Armstrongf99712c2023-06-01 17:04:38 -0400159coverage-out := ./tests/results/go-test-coverage.out
160coverage-xml := ./tests/results/go-test-coverage.xml
161
162results-out := ./tests/results/go-test-results.out
163results-xml := ./tests/results/go-test-results.xml
164
Matteo Scandolocedde462021-03-09 17:37:16 -0800165test-unit: clean local-omci-lib-go # @HELP Execute unit tests
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400166
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400167 $(call banner-enter,Target $@)
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400168
169 @mkdir -p $(dir $(results-out))
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400170
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400171 $(call banner,Running unit tests...)
172
173 $(if $(LOCAL_FIX_PERMS),\
174 chmod o+w $(dir $(results-out) $(results-out)))
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400175 set -euo pipefail \
176 && ${GO} test -mod=vendor -bench=. -v \
Joey Armstrongf99712c2023-06-01 17:04:38 -0400177 -coverprofile $(coverage-out) \
178 -covermode count ./... \
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400179 2>&1 | tee "$(results-out)"
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400180 $(if $(LOCAL_FIX_PERMS),\
181 chmod o-w $(dir $(results-out) $(results-out)))
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400182
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400183 $(call banner,Coverage report: junit)
184 $(if $(LOCAL_FIX_PERMS),\
185 chmod o+w $(dir $(results-xml) $(results-xml)))
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400186 ${GO_JUNIT_REPORT} < $(results-out) > $(results-xml)
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400187 $(if $(LOCAL_FIX_PERMS),\
188 chmod o-w $(dir $(results-xml) $(results-xml)))
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400189
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400190 $(call banner,Coverage report: Cobertura)
191 $(if $(LOCAL_FIX_PERMS),\
192 chmod o+w $(dir $(results-xml) $(coverage-xml)))
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400193 ${GOCOVER_COBERTURA} < $(coverage-out) > $(coverage-xml)
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400194 $(if $(LOCAL_FIX_PERMS),\
195 chmod o-w $(dir $(results-xml) $(coverage-xml)))
196
197 $(call banner,Coverage report directory perms:)
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400198
199 @echo
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400200 @/bin/ls -ld tests tests/results
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400201
202 @echo
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400203 @find $(dir $(results-out)) -print0 | xargs -0 ls -l
204 # chown -R $$(id -u):$$(id -g) $(dir $(results-xml)
205
206 $(call banner,Locally modified files: git status)
Joey Armstrong84b5bb92023-06-15 17:08:45 -0400207 git status
208
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400209 $(call banner-leave,Target $@)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700210
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400211## -----------------------------------------------------------------------
212## -----------------------------------------------------------------------
Kent Hagerman60d62302020-03-10 17:02:36 -0400213test-bbr: release-bbr docker-build # @HELP Validate that BBSim and BBR are working together
Joey Armstrong73d35792022-11-25 08:46:46 -0500214 DOCKER_RUN_ARGS="-pon 2 -onu 2" $(MAKE) docker-run
Matteo Scandolo569e7172019-12-20 11:51:51 -0800215 sleep 5
Matteo Scandoloc11074d2020-09-14 14:59:24 -0700216 ./$(RELEASE_DIR)/$(RELEASE_BBR_NAME)-linux-amd64 -pon 2 -onu 2 -logfile tmp.logs
Joey Armstrong73d35792022-11-25 08:46:46 -0500217 docker $(RM) -f bbsim
Matteo Scandolo569e7172019-12-20 11:51:51 -0800218
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400219## -----------------------------------------------------------------------
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400220## -----------------------------------------------------------------------
Matteo Scandolocedde462021-03-09 17:37:16 -0800221docker-build: local-omci-lib-go local-protos# @HELP Build the BBSim docker container (contains BBSimCtl too)
Kent Hagerman60d62302020-03-10 17:02:36 -0400222 docker build \
Joey Armstrong73d35792022-11-25 08:46:46 -0500223 -t "$(bbsim-tag)" \
Kent Hagerman60d62302020-03-10 17:02:36 -0400224 -f build/package/Dockerfile .
Matteo Scandolo4747d292019-08-05 11:50:18 -0700225
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400226## -----------------------------------------------------------------------
227## -----------------------------------------------------------------------
Matteo Scandolo01d41ce2019-10-28 15:42:47 -0700228docker-push: # @HELP Push the docker container to a registry
Joey Armstrong73d35792022-11-25 08:46:46 -0500229 docker push "$(bbsim-tag)"
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400230
231## -----------------------------------------------------------------------
232## -----------------------------------------------------------------------
Andrea Campanella64dffd52019-12-17 17:29:57 -0800233docker-kind-load:
234 @if [ "`kind get clusters | grep voltha-$(TYPE)`" = '' ]; then echo "no voltha-$(TYPE) cluster found" && exit 1; fi
Joey Armstrong73d35792022-11-25 08:46:46 -0500235 kind load docker-image "$(bbsim-tag)" --name=voltha-$(TYPE) --nodes $(shell kubectl get nodes --template='{{range .items}}{{.metadata.name}},{{end}}' | sed 's/,$$//')
236
237## -----------------------------------------------------------------------
238## docker-run
239## -----------------------------------------------------------------------
Joey Armstrong72558cb2022-11-30 06:35:52 -0500240
241# % docker run --detach unless dev-mode
242is-docker-run := $(filter-out %-dev,$(MAKECMDGOALS))
243is-docker-run := $(findstring docker-run,$(is-docker-run))
244
Joey Armstrong73d35792022-11-25 08:46:46 -0500245docker-run-cmd = docker run
Joey Armstrong72558cb2022-11-30 06:35:52 -0500246$(if $(is-docker-run),$(eval docker-run-cmd += --detach))
Joey Armstrong73d35792022-11-25 08:46:46 -0500247docker-run-cmd += ${DOCKER_PORTS}
248docker-run-cmd += --privileged
249docker-run-cmd += --rm
250docker-run-cmd += --name bbsim
251docker-run-cmd += "$(bbsim-tag)" /app/bbsim
252docker-run-cmd += ${DOCKER_RUN_ARGS}
Andrea Campanella64dffd52019-12-17 17:29:57 -0800253
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400254## -----------------------------------------------------------------------
255## -----------------------------------------------------------------------
Matteo Scandoloe383d5d2019-10-25 14:47:27 -0700256docker-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 -0500257 docker ps
Joey Armstrong72558cb2022-11-30 06:35:52 -0500258 $(docker-run-cmd)
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700259
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400260## -----------------------------------------------------------------------
261## -----------------------------------------------------------------------
Matteo Scandoloe383d5d2019-10-25 14:47:27 -0700262docker-run-dev: # @HELP Runs the container locally (intended for development purposes, not in detached mode)
Joey Armstrong73d35792022-11-25 08:46:46 -0500263 $(docker-run-cmd)
Matteo Scandoloe383d5d2019-10-25 14:47:27 -0700264
Joey Armstrong73d35792022-11-25 08:46:46 -0500265## -----------------------------------------------------------------------
266## docker-run
267## -----------------------------------------------------------------------
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700268.PHONY: docs docs-lint
Zdravko Bozakov2da76342019-10-21 09:47:35 +0200269docs: swagger # @HELP Generate docs and opens them in the browser
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400270
271 $(call begin-enter,Target $@)
272 -$(MAKE) -C docs html
273 $(call begin-leave,Target $@)
274
Zdravko Bozakov2da76342019-10-21 09:47:35 +0200275 @echo -e "\nBBSim documentation generated in file://${PWD}/docs/build/html/index.html"
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700276
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400277## -----------------------------------------------------------------------
278## -----------------------------------------------------------------------
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700279docs-lint:
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400280 $(MAKE) -C docs lint-doc8
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700281
Joey Armstrong5c610772023-01-23 16:03:32 -0500282## -----------------------------------------------------------------------
283## -----------------------------------------------------------------------
Joey Armstrong73d35792022-11-25 08:46:46 -0500284swagger-deps += docs/swagger/bbsim/bbsim.swagger.json
285swagger-deps += docs/swagger/leagacy/bbsim.swagger.json
286.PHONY: $(swagger-deps)
287swagger: $(swagger-deps) # @HELP Generate swagger documentation for BBSim API
Matteo Scandolo4747d292019-08-05 11:50:18 -0700288
Joey Armstrong73d35792022-11-25 08:46:46 -0500289## -----------------------------------------------------------------------
Matteo Scandoloca08fc72019-12-04 14:17:39 -0800290## Local Development Helpers
Joey Armstrong73d35792022-11-25 08:46:46 -0500291## -----------------------------------------------------------------------
Matteo Scandolocedde462021-03-09 17:37:16 -0800292local-omci-lib-go:
293ifdef LOCAL_OMCI_LIB_GO
294 mkdir -p vendor/github.com/opencord/omci-lib-go
295 cp -r ${LOCAL_OMCI_LIB_GO}/* vendor/github.com/opencord/omci-lib-go
Matteo Scandoloca08fc72019-12-04 14:17:39 -0800296endif
Matteo Scandolo4747d292019-08-05 11:50:18 -0700297
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400298## -----------------------------------------------------------------------
299## -----------------------------------------------------------------------
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700300local-protos: ## Copies a local version of the voltha-protos dependency into the vendor directory
301ifdef LOCAL_PROTOS
Joey Armstrong73d35792022-11-25 08:46:46 -0500302 $(RM) -r vendor/github.com/opencord/voltha-protos/v5/go
David K. Bainbridgec415efe2021-08-19 13:05:21 +0000303 mkdir -p vendor/github.com/opencord/voltha-protos/v5/go
304 cp -r ${LOCAL_PROTOS}/go/* vendor/github.com/opencord/voltha-protos/v5/go
Joey Armstrong73d35792022-11-25 08:46:46 -0500305 $(RM) -r vendor/github.com/opencord/voltha-protos/v5/go/vendor
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700306endif
307
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400308## -----------------------------------------------------------------------
309## -----------------------------------------------------------------------
310clean ::
Joey Armstrong73d35792022-11-25 08:46:46 -0500311 @$(RM) -f bbsim
312 @$(RM) -f bbsimctl
313 @$(RM) -f bbr
314 @$(RM) -r tools/bin
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400315 @$(RM) -r release
Matteo Scandolo3de9de02019-11-14 13:40:03 -0800316
Joey Armstrongf99712c2023-06-01 17:04:38 -0400317 @$(RM) $(coverage-out)
318 @$(RM) $(coverage-xml)
319
320 @$(RM) $(results-out)
321 @$(RM) $(results-xml)
322
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400323 @$(RM) $(sca-report-xml)
324
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400325sterile :: clean
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700326
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400327## -----------------------------------------------------------------------
328## -----------------------------------------------------------------------
Kent Hagerman60d62302020-03-10 17:02:36 -0400329setup_tools:
330 @echo "Downloading dependencies..."
David K. Bainbridgec415efe2021-08-19 13:05:21 +0000331 @${GO} mod download github.com/grpc-ecosystem/grpc-gateway github.com/opencord/voltha-protos/v5
Kent Hagerman60d62302020-03-10 17:02:36 -0400332 @echo "Dependencies downloaded OK"
Matteo Scandolo84f7d482019-08-08 19:00:47 -0700333
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400334## -----------------------------------------------------------------------
335## -----------------------------------------------------------------------
David K. Bainbridgec415efe2021-08-19 13:05:21 +0000336VOLTHA_PROTOS ?= $(shell ${GO} list -f '{{ .Dir }}' -m github.com/opencord/voltha-protos/v5)
Kent Hagerman60d62302020-03-10 17:02:36 -0400337GOOGLEAPI ?= $(shell ${GO} list -f '{{ .Dir }}' -m github.com/grpc-ecosystem/grpc-gateway)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700338
Joey Armstrong73d35792022-11-25 08:46:46 -0500339.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 -0400340api/openolt/openolt.pb.go: api/openolt/openolt.proto setup_tools
341 @echo $@
342 @${PROTOC} -I. \
343 -I${GOOGLEAPI}/third_party/googleapis \
amit.ghoshee17c002021-06-10 12:14:38 +0200344 --go_out=plugins=grpc:./ --go_opt=paths=source_relative \
Kent Hagerman60d62302020-03-10 17:02:36 -0400345 $<
Zdravko Bozakov2da76342019-10-21 09:47:35 +0200346
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400347## -----------------------------------------------------------------------
348## -----------------------------------------------------------------------
hkouser24361d42020-12-14 19:21:47 +0530349api/bbsim/bbsim_dmi.pb.go: api/bbsim/bbsim_dmi.proto setup_tools
350 @echo $@
351 @${PROTOC} -I. \
352 -I${GOOGLEAPI}/third_party/googleapis \
amit.ghoshee17c002021-06-10 12:14:38 +0200353 --go_out=plugins=grpc:./ --go_opt=paths=source_relative \
hkouser24361d42020-12-14 19:21:47 +0530354 $<
355
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400356## -----------------------------------------------------------------------
357## -----------------------------------------------------------------------
Kent Hagerman60d62302020-03-10 17:02:36 -0400358api/bbsim/bbsim.pb.go api/bbsim/bbsim.pb.gw.go: api/bbsim/bbsim.proto api/bbsim/bbsim.yaml setup_tools
359 @echo $@
360 @${PROTOC} -I. \
361 -I${GOOGLEAPI}/third_party/googleapis \
362 -I${VOLTHA_PROTOS}/protos/ \
amit.ghoshee17c002021-06-10 12:14:38 +0200363 --go_out=plugins=grpc:./ --go_opt=paths=source_relative \
364 --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 -0400365 $<
Zdravko Bozakov2da76342019-10-21 09:47:35 +0200366
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400367## -----------------------------------------------------------------------
368## -----------------------------------------------------------------------
Kent Hagerman60d62302020-03-10 17:02:36 -0400369api/legacy/bbsim.pb.go api/legacy/bbsim.pb.gw.go: api/legacy/bbsim.proto setup_tools
370 @echo $@
371 @${PROTOC} -I. \
372 -I${GOOGLEAPI}/third_party/googleapis/ \
373 -I${GOOGLEAPI}/ \
374 -I${VOLTHA_PROTOS}/protos/ \
375 --go_out=plugins=grpc:./ \
amit.ghoshee17c002021-06-10 12:14:38 +0200376 --grpc-gateway_out=logtostderr=true,paths=source_relative,allow_delete_body=true:./ \
Kent Hagerman60d62302020-03-10 17:02:36 -0400377 $<
378
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400379## -----------------------------------------------------------------------
380## -----------------------------------------------------------------------
Kent Hagerman60d62302020-03-10 17:02:36 -0400381docs/swagger/bbsim/bbsim.swagger.json: api/bbsim/bbsim.yaml setup_tools
382 @echo $@
383 @${PROTOC} -I ./api \
384 -I${GOOGLEAPI}/ \
385 -I${VOLTHA_PROTOS}/protos/ \
Zack Williamsd2907e62020-04-03 10:23:02 -0700386 --swagger_out=logtostderr=true,allow_delete_body=true,disable_default_errors=true,grpc_api_configuration=$<:docs/swagger/ \
Kent Hagerman60d62302020-03-10 17:02:36 -0400387 api/bbsim/bbsim.proto
388
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400389## -----------------------------------------------------------------------
390## -----------------------------------------------------------------------
Kent Hagerman60d62302020-03-10 17:02:36 -0400391docs/swagger/leagacy/bbsim.swagger.json: api/legacy/bbsim.proto setup_tools
392 @echo $@
393 @${PROTOC} -I ./api \
394 -I${GOOGLEAPI}/ \
395 -I${VOLTHA_PROTOS}/protos/ \
Zack Williamsd2907e62020-04-03 10:23:02 -0700396 --swagger_out=logtostderr=true,allow_delete_body=true,disable_default_errors=true:docs/swagger/ \
Kent Hagerman60d62302020-03-10 17:02:36 -0400397 $<
Joey Armstrong73d35792022-11-25 08:46:46 -0500398
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400399## -----------------------------------------------------------------------
Joey Armstrong96bcf1b2023-06-27 14:49:40 -0400400## Intent:
401## -----------------------------------------------------------------------
402clean ::
403 $(RM) -r "docs/$(venv-name)"
404
405## -----------------------------------------------------------------------
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400406## Intent: Helper target used to exercise release script changes
407## -----------------------------------------------------------------------
Joey Armstrong2c850cc2023-04-17 16:30:00 -0400408include $(MAKEDIR)/release/onf-publish.mk
Joey Armstrong36c9bcd2023-04-05 19:05:56 -0400409
410$(if $(DEBUG),$(warning LEAVE))
411
Joey Armstrong2c039362024-02-04 18:51:52 -0500412# [EOF] x 2