1# SPDX-License-Identifier: BSD-3-Clause 2# Copyright (c) Intel Corporation. 3# All rights reserved. 4# 5 6SPDK_ROOT_DIR := $(abspath $(CURDIR)/..) 7include $(SPDK_ROOT_DIR)/mk/spdk.common.mk 8 9define generate_protobuf 10$(1)/%_pb2.py $(1)/%_pb2_grpc.py: $(1)/%.proto 11 $(Q)python3 -m grpc_tools.protoc -I $(1) --python_out=$(1) \ 12 --grpc_python_out=$(1) --proto_path=$(1) $$^ 13endef 14 15ifeq ($(CONFIG_SMA),y) 16protodirs = spdk/sma/proto 17protodefs = $(foreach protodir,$(protodirs),$(wildcard $(protodir)/*.proto)) 18protopy = $(foreach proto,$(basename $(protodefs)),$(addprefix $(proto),_pb2.py _pb2_grpc.py)) 19endif 20 21all: $(protopy) 22 23clean: 24 $(Q)$(RM) $(protopy) 25 26# TODO: we should probably write a proper install rule here instead of just blindly copying all 27# python scripts when building the RPMs 28install: 29uninstall: 30 31$(foreach protodir,$(protodirs),$(eval $(call generate_protobuf,$(protodir)))) 32 33.PHONY: all clean install uninstall 34