Joey Armstrong | e6cdd8e | 2022-12-29 11:58:15 -0500 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | 0cbed33 | 2024-07-17 18:10:46 -0400 | [diff] [blame] | 3 | # Copyright 2019-2024 Open Networking Foundation Contributors |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -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 | e6cdd8e | 2022-12-29 11:58:15 -0500 | [diff] [blame] | 16 | # ----------------------------------------------------------------------- |
Joey Armstrong | 0cbed33 | 2024-07-17 18:10:46 -0400 | [diff] [blame] | 17 | # SPDX-FileCopyrightText: 2019-2024 Open Networking Foundation Contributors |
| 18 | # SPDX-License-Identifier: Apache-2.0 |
| 19 | # ----------------------------------------------------------------------- |
Joey Armstrong | e6cdd8e | 2022-12-29 11:58:15 -0500 | [diff] [blame] | 20 | |
Joey Armstrong | e66eaaf | 2023-01-15 18:58:52 -0500 | [diff] [blame] | 21 | .PHONY: test |
Joey Armstrong | 0cbed33 | 2024-07-17 18:10:46 -0400 | [diff] [blame] | 22 | export .DEFAULT_GOAL := test |
Joey Armstrong | e6cdd8e | 2022-12-29 11:58:15 -0500 | [diff] [blame] | 23 | |
Joey Armstrong | e66eaaf | 2023-01-15 18:58:52 -0500 | [diff] [blame] | 24 | ##-------------------## |
| 25 | ##---] GLOBALS [---## |
| 26 | ##-------------------## |
Eric Ball | f1055a9 | 2024-09-05 11:01:28 -0700 | [diff] [blame] | 27 | TOP ?= . |
| 28 | MAKEDIR ?= $(TOP)/makefiles |
Joey Armstrong | e6cdd8e | 2022-12-29 11:58:15 -0500 | [diff] [blame] | 29 | |
Eric Ball | f1055a9 | 2024-09-05 11:01:28 -0700 | [diff] [blame] | 30 | $(if $(VERBOSE),$(eval export VERBOSE=$(VERBOSE))) # visible to include(s) |
Joey Armstrong | e6cdd8e | 2022-12-29 11:58:15 -0500 | [diff] [blame] | 31 | |
Joey Armstrong | 761579c | 2023-05-08 11:59:57 -0400 | [diff] [blame] | 32 | ##-------------------------- |
| 33 | ## Enable setup.py debugging |
| 34 | ##-------------------------- |
| 35 | # https://docs.python.org/3/distutils/setupscript.html#debugging-the-setup-script |
Joey Armstrong | 56b3678 | 2023-05-30 17:30:11 -0400 | [diff] [blame] | 36 | # export DISTUTILS_DEBUG := 1 # verbose: pip |
| 37 | export DOCKER_DEBUG := 1 # verbose: docker |
Joey Armstrong | 761579c | 2023-05-08 11:59:57 -0400 | [diff] [blame] | 38 | |
Eric Ball | f1055a9 | 2024-09-05 11:01:28 -0700 | [diff] [blame] | 39 | # Makefile for voltha-protos |
| 40 | default: test |
| 41 | |
| 42 | ## Library linting |
| 43 | # NO-LINT-MAKEFILE := true # cleanup needed |
| 44 | NO-LINT-SHELL := true # cleanup needed |
| 45 | |
| 46 | ##--------------------## |
| 47 | ##---] INCLUDES [---## |
| 48 | ##--------------------## |
| 49 | include $(MAKEDIR)/include.mk |
| 50 | |
Zack Williams | 43bfd9e | 2019-04-12 13:09:31 -0700 | [diff] [blame] | 51 | # Function to extract the last path component from go_package line in .proto files |
| 52 | define go_package_path |
| 53 | $(shell grep go_package $(1) | sed -n 's/.*\/\(.*\)";/\1/p') |
| 54 | endef |
| 55 | |
Joey Armstrong | e05f649 | 2023-05-31 11:27:31 -0400 | [diff] [blame] | 56 | # ----------------------------------------------------------------------- |
Serkant Uluderya | cbcfaa4 | 2019-10-18 13:25:08 +0300 | [diff] [blame] | 57 | # Function to extract the last path component from package line in .proto files |
Joey Armstrong | e05f649 | 2023-05-31 11:27:31 -0400 | [diff] [blame] | 58 | # % grep 'package' will match: |
| 59 | # o package <name> ; |
| 60 | # o option java_package='<dot-pkg-fqdn> |
| 61 | # ----------------------------------------------------------------------- |
| 62 | # RETURN: protos/voltha_protos/common.proto => common |
| 63 | # ----------------------------------------------------------------------- |
Serkant Uluderya | cbcfaa4 | 2019-10-18 13:25:08 +0300 | [diff] [blame] | 64 | define java_package_path |
| 65 | $(shell grep package $(1) | sed -n 's/.*\/\(.*\)";/\1/p') |
| 66 | endef |
| 67 | |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 68 | # Variables |
Zack Williams | 43bfd9e | 2019-04-12 13:09:31 -0700 | [diff] [blame] | 69 | PROTO_FILES := $(sort $(wildcard protos/voltha_protos/*.proto)) |
| 70 | |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 71 | PROTO_PYTHON_DEST_DIR := python/voltha_protos |
| 72 | PROTO_PYTHON_PB2 := $(foreach f, $(PROTO_FILES), $(patsubst protos/voltha_protos/%.proto,$(PROTO_PYTHON_DEST_DIR)/%_pb2.py,$(f))) |
Matt Jeanneret | 37e0fc6 | 2019-03-07 12:33:21 -0500 | [diff] [blame] | 73 | PROTO_PYTHON_PB2_GRPC := $(foreach f, $(PROTO_FILES), $(patsubst protos/voltha_protos/%.proto,$(PROTO_PYTHON_DEST_DIR)/%_pb2_grpc.py,$(f))) |
Zack Williams | 43bfd9e | 2019-04-12 13:09:31 -0700 | [diff] [blame] | 74 | PROTO_GO_DEST_DIR := go |
| 75 | PROTO_GO_PB:= $(foreach f, $(PROTO_FILES), $(patsubst protos/voltha_protos/%.proto,$(PROTO_GO_DEST_DIR)/$(call go_package_path,$(f))/%.pb.go,$(f))) |
Serkant Uluderya | cbcfaa4 | 2019-10-18 13:25:08 +0300 | [diff] [blame] | 76 | PROTO_JAVA_DEST_DIR := java |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 77 | PROTO_JAVA_PB := $(foreach f, $(PROTO_FILES), $(patsubst protos/voltha_protos/%.proto,$(PROTO_JAVA_DEST_DIR)/$(call java_package_path,$(f))/%.pb.java,$(f))) |
Joey Armstrong | 761579c | 2023-05-08 11:59:57 -0400 | [diff] [blame] | 78 | |
Eric Ball | f1055a9 | 2024-09-05 11:01:28 -0700 | [diff] [blame] | 79 | # Force pb file to be regenrated every time. Otherwise the make process assumes generated version is still valid |
Kent Hagerman | 868dc38 | 2020-01-20 11:24:09 -0500 | [diff] [blame] | 80 | .PHONY: voltha.pb |
Matt Jeanneret | 15249fa | 2019-04-12 20:25:31 -0400 | [diff] [blame] | 81 | |
Joey Armstrong | e0c1a8d | 2023-04-13 15:16:21 -0400 | [diff] [blame] | 82 | ##----------------## |
| 83 | ##---] DEPS [---## |
| 84 | ##----------------## |
| 85 | infra-deps := $(null) |
| 86 | infra-deps += Makefile |
| 87 | infra-deps += $(venv-activate-script) |
| 88 | |
| 89 | ## ----------------------------------------------------------------------- |
| 90 | ## ----------------------------------------------------------------------- |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 91 | print: |
Zack Williams | 43bfd9e | 2019-04-12 13:09:31 -0700 | [diff] [blame] | 92 | @echo "Proto files: $(PROTO_FILES)" |
| 93 | @echo "Python PB2 files: $(PROTO_PYTHON_PB2)" |
| 94 | @echo "Go PB files: $(PROTO_GO_PB)" |
Serkant Uluderya | cbcfaa4 | 2019-10-18 13:25:08 +0300 | [diff] [blame] | 95 | @echo "JAVA PB files: $(PROTO_JAVA_PB)" |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 96 | |
Joey Armstrong | 0cbed33 | 2024-07-17 18:10:46 -0400 | [diff] [blame] | 97 | ## ----------------------------------------------------------------------- |
| 98 | ## Generic targets |
| 99 | ## ----------------------------------------------------------------------- |
| 100 | .PHONY: protos |
Serkant Uluderya | cbcfaa4 | 2019-10-18 13:25:08 +0300 | [diff] [blame] | 101 | protos: python-protos go-protos java-protos |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 102 | |
Joey Armstrong | 0cbed33 | 2024-07-17 18:10:46 -0400 | [diff] [blame] | 103 | .PHONY: build |
| 104 | build: protos python-build |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 105 | |
Joey Armstrong | 0cbed33 | 2024-07-17 18:10:46 -0400 | [diff] [blame] | 106 | .PHONY: test |
Serkant Uluderya | cbcfaa4 | 2019-10-18 13:25:08 +0300 | [diff] [blame] | 107 | test: python-test go-test java-test |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 108 | |
Joey Armstrong | 761579c | 2023-05-08 11:59:57 -0400 | [diff] [blame] | 109 | clean :: python-clean java-clean go-clean |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 110 | |
Joey Armstrong | 761579c | 2023-05-08 11:59:57 -0400 | [diff] [blame] | 111 | sterile :: clean |
Joey Armstrong | c227765 | 2023-01-11 17:41:36 -0500 | [diff] [blame] | 112 | |
Joey Armstrong | e0c1a8d | 2023-04-13 15:16:21 -0400 | [diff] [blame] | 113 | ## ----------------------------------------------------------------------- |
| 114 | ## Python targets |
| 115 | ## ----------------------------------------------------------------------- |
| 116 | python-protos: $(infra-deps) $(PROTO_PYTHON_PB2) |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 117 | |
Joey Armstrong | 761579c | 2023-05-08 11:59:57 -0400 | [diff] [blame] | 118 | ## ----------------------------------------------------------------------- |
| 119 | ## ----------------------------------------------------------------------- |
| 120 | $(PROTO_PYTHON_DEST_DIR)/%_pb2.py: \ |
| 121 | protos/voltha_protos/%.proto \ |
| 122 | Makefile \ |
| 123 | $(venv-activate-script) |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 124 | |
| 125 | @echo |
| 126 | @echo "** -----------------------------------------------------------------------" |
| 127 | @echo "** $(MAKE): processing target [$@]" |
| 128 | @echo "** -----------------------------------------------------------------------" |
| 129 | |
| 130 | $(activate) && python -m grpc_tools.protoc \ |
Zack Williams | 43bfd9e | 2019-04-12 13:09:31 -0700 | [diff] [blame] | 131 | -I protos \ |
| 132 | --python_out=python \ |
| 133 | --grpc_python_out=python \ |
| 134 | --descriptor_set_out=$(PROTO_PYTHON_DEST_DIR)/$(basename $(notdir $<)).desc \ |
| 135 | --include_imports \ |
| 136 | --include_source_info \ |
| 137 | $< |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 138 | |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 139 | ## ----------------------------------------------------------------------- |
| 140 | ## Intent: |
| 141 | ## ----------------------------------------------------------------------- |
| 142 | show: |
| 143 | $(call banner-enter,target $@) |
| 144 | @echo |
| 145 | $(call banner-leave,target $@) |
| 146 | |
| 147 | ## ----------------------------------------------------------------------- |
| 148 | ## Intent: |
| 149 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 6a6c629 | 2024-04-30 16:07:38 -0400 | [diff] [blame] | 150 | python-build: setup.py python-protos |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 151 | |
| 152 | $(call banner-enter,target $@) |
| 153 | |
Joey Armstrong | e6cdd8e | 2022-12-29 11:58:15 -0500 | [diff] [blame] | 154 | $(RM) -r dist/ |
Joey Armstrong | 0cbed33 | 2024-07-17 18:10:46 -0400 | [diff] [blame] | 155 | $(activate) && python ./setup.py sdist |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 156 | |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 157 | $(call banner-leave,target $@) |
| 158 | |
| 159 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 6a6c629 | 2024-04-30 16:07:38 -0400 | [diff] [blame] | 160 | ## Intent: Invoke tox to install a python interpreter then run tests. |
| 161 | ## ----------------------------------------------------------------------- |
| 162 | ## See Also: |
| 163 | ## o https://tox.wiki/en/latest/cli_interface.html#tox-verbosity |
| 164 | ## every -v increases, every -q decreases verbosity level, |
| 165 | ## default WARNING (level:2) |
| 166 | ## map 0=CRITICAL|1=ERROR|2=WARNING|3=INFO|4=DEBUG|5=NOTSET |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 167 | ## ----------------------------------------------------------------------- |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 168 | python-test: tox.ini setup.py python-protos |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 169 | $(call banner-enter,target $@) |
Joey Armstrong | 6a6c629 | 2024-04-30 16:07:38 -0400 | [diff] [blame] | 170 | |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 171 | $(activate) && python --version |
Joey Armstrong | 6a6c629 | 2024-04-30 16:07:38 -0400 | [diff] [blame] | 172 | tox -vvv |
| 173 | |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 174 | $(call banner-leave,target $@) |
| 175 | |
| 176 | ## ----------------------------------------------------------------------- |
| 177 | ## Intent: |
| 178 | ## ----------------------------------------------------------------------- |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 179 | python-clean: |
Joey Armstrong | e66eaaf | 2023-01-15 18:58:52 -0500 | [diff] [blame] | 180 | find python -name '__pycache__' -type d -print0 \ |
| 181 | | xargs -0 --no-run-if-empty $(RM) -r |
Joey Armstrong | c227765 | 2023-01-11 17:41:36 -0500 | [diff] [blame] | 182 | find python -name '*.pyc' -type f -print0 \ |
| 183 | | xargs -0 --no-run-if-empty $(RM) |
Joey Armstrong | e6cdd8e | 2022-12-29 11:58:15 -0500 | [diff] [blame] | 184 | $(RM) -r \ |
Zack Williams | 43bfd9e | 2019-04-12 13:09:31 -0700 | [diff] [blame] | 185 | .coverage \ |
| 186 | .tox \ |
| 187 | coverage.xml \ |
| 188 | dist \ |
| 189 | nose2-results.xml \ |
| 190 | python/__pycache__ \ |
| 191 | python/test/__pycache__ \ |
| 192 | python/voltha_protos.egg-info \ |
Joey Armstrong | 761579c | 2023-05-08 11:59:57 -0400 | [diff] [blame] | 193 | "$(venv-abs-path)" \ |
Zack Williams | 43bfd9e | 2019-04-12 13:09:31 -0700 | [diff] [blame] | 194 | $(PROTO_PYTHON_DEST_DIR)/*.desc \ |
| 195 | $(PROTO_PYTHON_PB2) \ |
| 196 | $(PROTO_PYTHON_PB2_GRPC) |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 197 | |
Joey Armstrong | 761579c | 2023-05-08 11:59:57 -0400 | [diff] [blame] | 198 | ## ----------------------------------------------------------------------- |
| 199 | ## Intent: Revert go to a clean state. |
| 200 | ## o TODO - go/ directory should not be placed under revision control. |
| 201 | ## o Build should retrieve versioned sources from a central repo. |
| 202 | ## ----------------------------------------------------------------------- |
khenaidoo | 5fc5cea | 2021-08-11 17:39:16 -0400 | [diff] [blame] | 203 | go-clean: |
Joey Armstrong | e6cdd8e | 2022-12-29 11:58:15 -0500 | [diff] [blame] | 204 | $(RM) -r go/* |
Joey Armstrong | 761579c | 2023-05-08 11:59:57 -0400 | [diff] [blame] | 205 | $(HIDE)$(MAKE) repair |
| 206 | |
| 207 | ## ----------------------------------------------------------------------- |
| 208 | ## Intent: Recover from a fatal failed build state: |
| 209 | ## o build removes go/ while regenerating prototypes. |
| 210 | ## o chicken-n-egg: make becomes fatal when go/ is removed and proten fails. |
| 211 | ## ----------------------------------------------------------------------- |
| 212 | repair: |
| 213 | /usr/bin/env git checkout go |
| 214 | |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 215 | ## ----------------------------------------------------------------------- |
| 216 | ## Intent: Go targets |
| 217 | ## ----------------------------------------------------------------------- |
Kent Hagerman | 868dc38 | 2020-01-20 11:24:09 -0500 | [diff] [blame] | 218 | go-protos: voltha.pb |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 219 | |
Joey Armstrong | 56b3678 | 2023-05-30 17:30:11 -0400 | [diff] [blame] | 220 | $(call banner-enter,target $@) |
Joey Armstrong | 5008009 | 2023-07-06 15:18:37 -0400 | [diff] [blame] | 221 | @echo "** Creating *.go.pb files" |
Joey Armstrong | 1ff23e9 | 2023-07-13 16:24:32 -0400 | [diff] [blame] | 222 | |
Joey Armstrong | ba3d9d1 | 2024-01-15 14:22:11 -0500 | [diff] [blame] | 223 | $(if $(LOCAL_FIX_PERMS),chmod -R o+w $(PROTO_GO_DEST_DIR)) |
| 224 | |
Joey Armstrong | 761579c | 2023-05-08 11:59:57 -0400 | [diff] [blame] | 225 | ${PROTOC_SH} $(quote-double)\ |
Kent Hagerman | 868dc38 | 2020-01-20 11:24:09 -0500 | [diff] [blame] | 226 | set -e -o pipefail; \ |
| 227 | for x in ${PROTO_FILES}; do \ |
| 228 | echo \$$x; \ |
| 229 | protoc --go_out=plugins=grpc:/go/src -I protos \$$x; \ |
Joey Armstrong | 56b3678 | 2023-05-30 17:30:11 -0400 | [diff] [blame] | 230 | done\ |
| 231 | $(quote-double) |
| 232 | |
Joey Armstrong | ba3d9d1 | 2024-01-15 14:22:11 -0500 | [diff] [blame] | 233 | $(if $(LOCAL_FIX_PERMS),chmod -R o-w $(PROTO_GO_DEST_DIR)) |
| 234 | |
Joey Armstrong | 56b3678 | 2023-05-30 17:30:11 -0400 | [diff] [blame] | 235 | $(call banner-leave,target $@) |
Zack Williams | 43bfd9e | 2019-04-12 13:09:31 -0700 | [diff] [blame] | 236 | |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 237 | ## ----------------------------------------------------------------------- |
Eric Ball | f1055a9 | 2024-09-05 11:01:28 -0700 | [diff] [blame] | 238 | ## Intent: |
Joey Armstrong | 56b3678 | 2023-05-30 17:30:11 -0400 | [diff] [blame] | 239 | ## ---------------------------------------------------------------------- |
Eric Ball | f1055a9 | 2024-09-05 11:01:28 -0700 | [diff] [blame] | 240 | voltha.pb: show-proto-files |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 241 | $(call banner-enter,target $@) |
| 242 | |
| 243 | ${PROTOC} \ |
| 244 | -I protos \ |
| 245 | -I protos/google/api \ |
| 246 | --include_imports \ |
| 247 | --include_source_info \ |
Kent Hagerman | 868dc38 | 2020-01-20 11:24:09 -0500 | [diff] [blame] | 248 | --descriptor_set_out=$@ \ |
| 249 | ${PROTO_FILES} |
Zack Williams | 43bfd9e | 2019-04-12 13:09:31 -0700 | [diff] [blame] | 250 | |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 251 | $(call banner-leave,target $@) |
| 252 | |
| 253 | ## ----------------------------------------------------------------------- |
| 254 | ## Intent: |
| 255 | ## ----------------------------------------------------------------------- |
Kent Hagerman | 868dc38 | 2020-01-20 11:24:09 -0500 | [diff] [blame] | 256 | go-test: |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 257 | $(call banner-enter,target $@) |
| 258 | |
William Kurkian | ad74565 | 2019-03-20 08:45:51 -0400 | [diff] [blame] | 259 | test/test-go-proto-consistency.sh |
Kent Hagerman | 868dc38 | 2020-01-20 11:24:09 -0500 | [diff] [blame] | 260 | ${GO} mod verify |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 261 | |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 262 | $(call banner-leave,target $@) |
| 263 | |
| 264 | ## ----------------------------------------------------------------------- |
| 265 | ## Intent: Java targets |
| 266 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 56b3678 | 2023-05-30 17:30:11 -0400 | [diff] [blame] | 267 | |
| 268 | java-protos-dirs += java_temp/src/main/java |
| 269 | java-protos-dirs += java_temp/src/main/java/org |
| 270 | # local docker problem |
| 271 | java-protos-dirs += java_temp/src/main/java/org/opencord/voltha/adapter |
| 272 | java-protos-dirs += java_temp/src/main/java/org/opencord/voltha/adapter_service |
| 273 | |
| 274 | mkdir-args += -vp |
Joey Armstrong | 56b3678 | 2023-05-30 17:30:11 -0400 | [diff] [blame] | 275 | |
Kent Hagerman | 868dc38 | 2020-01-20 11:24:09 -0500 | [diff] [blame] | 276 | java-protos: voltha.pb |
Joey Armstrong | 56b3678 | 2023-05-30 17:30:11 -0400 | [diff] [blame] | 277 | |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 278 | $(call banner-enter,target $@) |
| 279 | |
Joey Armstrong | 56b3678 | 2023-05-30 17:30:11 -0400 | [diff] [blame] | 280 | mkdir $(mkdir-args) $(java-protos-dirs) |
Joey Armstrong | cb986bf | 2023-12-12 17:22:05 -0500 | [diff] [blame] | 281 | |
Joey Armstrong | 56b3678 | 2023-05-30 17:30:11 -0400 | [diff] [blame] | 282 | $(docker-sh) $(quote-double) find $(java-protos-dirs) -print0 \ |
| 283 | | xargs -0 -n1 /bin/ls -ld $(quote-double) |
| 284 | |
Joey Armstrong | cb986bf | 2023-12-12 17:22:05 -0500 | [diff] [blame] | 285 | $(if $(LOCAL_FIX_PERMS),chmod -R o+w java_temp) |
Joey Armstrong | 761579c | 2023-05-08 11:59:57 -0400 | [diff] [blame] | 286 | @${PROTOC_SH} $(quote-double) \ |
Kent Hagerman | 868dc38 | 2020-01-20 11:24:09 -0500 | [diff] [blame] | 287 | set -e -o pipefail; \ |
| 288 | for x in ${PROTO_FILES}; do \ |
| 289 | echo \$$x; \ |
| 290 | protoc --java_out=java_temp/src/main/java -I protos \$$x; \ |
Joey Armstrong | 56b3678 | 2023-05-30 17:30:11 -0400 | [diff] [blame] | 291 | done\ |
| 292 | $(quote-double) |
Joey Armstrong | cb986bf | 2023-12-12 17:22:05 -0500 | [diff] [blame] | 293 | $(if $(LOCAL_FIX_PERMS),chmod -R o-w java_temp) |
Serkant Uluderya | cbcfaa4 | 2019-10-18 13:25:08 +0300 | [diff] [blame] | 294 | |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 295 | # Move files into place after all prototypes have generated. |
| 296 | # TODO: Remove the extra step, use makefile deps and |
| 297 | # generate in-place as needed. |
| 298 | @mkdir -p java |
Joey Armstrong | 5008009 | 2023-07-06 15:18:37 -0400 | [diff] [blame] | 299 | rsync -r --checksum java_temp/src/main/java/. java/. |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 300 | |
| 301 | $(call banner-leave,target $@) |
| 302 | |
| 303 | ## ----------------------------------------------------------------------- |
| 304 | ## Intent: Tests if the generated java classes are compilable |
| 305 | ## ----------------------------------------------------------------------- |
Serkant Uluderya | cbcfaa4 | 2019-10-18 13:25:08 +0300 | [diff] [blame] | 306 | java-test: java-protos |
| 307 | cp test/pom.xml java_temp |
| 308 | cd java_temp && mvn compile |
| 309 | |
Joey Armstrong | 670d40c | 2023-05-11 20:49:26 -0400 | [diff] [blame] | 310 | ## ----------------------------------------------------------------------- |
| 311 | ## Intent: Custodial service |
| 312 | ## ----------------------------------------------------------------------- |
Serkant Uluderya | cbcfaa4 | 2019-10-18 13:25:08 +0300 | [diff] [blame] | 313 | java-clean: |
Joey Armstrong | e6cdd8e | 2022-12-29 11:58:15 -0500 | [diff] [blame] | 314 | $(RM) -r java |
| 315 | $(RM) -r java_temp |
| 316 | |
Joey Armstrong | 56b3678 | 2023-05-30 17:30:11 -0400 | [diff] [blame] | 317 | ## ----------------------------------------------------------------------- |
| 318 | ## Intent: Placeholder for library targets |
| 319 | ## ----------------------------------------------------------------------- |
Joey Armstrong | e66eaaf | 2023-01-15 18:58:52 -0500 | [diff] [blame] | 320 | lint : |
| 321 | |
Joey Armstrong | 56b3678 | 2023-05-30 17:30:11 -0400 | [diff] [blame] | 322 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 5008009 | 2023-07-06 15:18:37 -0400 | [diff] [blame] | 323 | ## Intent: Make sterile is unrecoverable due to handling of java_temp |
| 324 | ## ----------------------------------------------------------------------- |
| 325 | protos-clean: |
| 326 | $(MAKE) sterile |
| 327 | $(MAKE) build |
| 328 | $(MAKE) protos |
| 329 | $(MAKE) test |
| 330 | |
| 331 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 56b3678 | 2023-05-30 17:30:11 -0400 | [diff] [blame] | 332 | ## Intent: Display/debug targets |
| 333 | ## ----------------------------------------------------------------------- |
| 334 | .PHONY: show-proto-files |
| 335 | show-proto-files: |
Joey Armstrong | 1ff23e9 | 2023-07-13 16:24:32 -0400 | [diff] [blame] | 336 | |
| 337 | $(call banner-enter,Target $@) |
| 338 | @echo -e "PROTO_FILES:\n$(PROTO_FILES)" | tr ' ' '\n' |
| 339 | $(call banner-leave,Target $@) |
Joey Armstrong | 56b3678 | 2023-05-30 17:30:11 -0400 | [diff] [blame] | 340 | |
Joey Armstrong | e6cdd8e | 2022-12-29 11:58:15 -0500 | [diff] [blame] | 341 | # [EOF] |