build: move protobuf files to a top-level directory

Up until now, the protobuf files were all located under
`python/spdk/sma/proto`.  This was fine, as they were only used in SMA
and we only generated python code.  However, now, we would also like to
to output code for other (e.g. go) languages too, so it no longer make
sense to keep them under `python`.

Only the protobuf files will be stored under `proto`.  The autogenerated
python code will remain under `python`, while the go code will be put in
the `go` directory.

While here, simplified the Makefile by removing a function generating
rules based on a directory, because we keep all protobuf files in the
same location.

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I4dcb7b33cd6f2930732f04dee62e35571b09315b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15016
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Konrad Sztyber 2022-10-17 11:51:22 +02:00 committed by Tomasz Zawadzki
parent 1f3a6b0398
commit c996aff28d
7 changed files with 8 additions and 13 deletions

View File

@ -19,7 +19,7 @@ DIRS-y += test
DIRS-$(CONFIG_IPSEC_MB) += ipsecbuild
DIRS-$(CONFIG_ISAL) += isalbuild
DIRS-$(CONFIG_VFIO_USER) += vfiouserbuild
DIRS-y += python
DIRS-$(CONFIG_SMA) += proto
DIRS-$(CONFIG_XNVME) += xnvmebuild
.PHONY: all clean $(DIRS-y) include/spdk/config.h mk/config.mk \

View File

@ -6,17 +6,10 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
define generate_protobuf
$(1)/%_pb2.py $(1)/%_pb2_grpc.py: $(1)/%.proto
$(Q)python3 -m grpc_tools.protoc -I $(1) --python_out=$(1) \
--grpc_python_out=$(1) --proto_path=$(1) $$^
endef
ifeq ($(CONFIG_SMA),y)
protodirs = spdk/sma/proto
protodefs = $(foreach protodir,$(protodirs),$(wildcard $(protodir)/*.proto))
protopy = $(foreach proto,$(basename $(protodefs)),$(addprefix $(proto),_pb2.py _pb2_grpc.py))
endif
# Location where the python generated code is placed
pydir=$(SPDK_ROOT_DIR)/python/spdk/sma/proto
protodefs = $(wildcard *.proto)
protopy = $(foreach proto,$(basename $(protodefs)),$(addprefix $(pydir)/$(proto),_pb2.py _pb2_grpc.py))
all: $(protopy)
@ -28,6 +21,8 @@ clean:
install:
uninstall:
$(foreach protodir,$(protodirs),$(eval $(call generate_protobuf,$(protodir))))
$(pydir)/%_pb2.py $(pydir)/%_pb2_grpc.py: %.proto
$(Q)python3 -m grpc_tools.protoc --proto_path=. --python_out=$(pydir) \
--grpc_python_out=$(pydir) $^
.PHONY: all clean install uninstall