Fix dependencies of protoc with nanopb-c plugin
Bug: 27954979
Change-Id: Ic06b5288b092d8ea5225516069845bfc2ffa9cd1
diff --git a/core/binary.mk b/core/binary.mk
index 280e0ba..3daecb2 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -647,21 +647,23 @@
ifneq ($(proto_sources),)
proto_generated_sources_dir := $(generated_sources_dir)/proto
proto_generated_obj_dir := $(intermediates)/proto
+proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
ifneq (,$(filter nanopb-c nanopb-c-enable_malloc, $(LOCAL_PROTOC_OPTIMIZE_TYPE)))
my_proto_source_suffix := .c
my_proto_c_includes := external/nanopb-c
my_protoc_flags := --nanopb_out=$(proto_generated_sources_dir) \
--plugin=external/nanopb-c/generator/protoc-gen-nanopb
+my_protoc_deps := $(NANOPB_SRCS) $(proto_sources_fullpath:%.proto=%.options)
else
my_proto_source_suffix := .cc
my_proto_c_includes := external/protobuf/src
my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
my_protoc_flags := --cpp_out=$(proto_generated_sources_dir)
+my_protoc_deps :=
endif
my_proto_c_includes += $(proto_generated_sources_dir)
-proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
proto_generated_sources := $(addprefix $(proto_generated_sources_dir)/, \
$(patsubst %.proto,%.pb$(my_proto_source_suffix),$(proto_sources_fullpath)))
proto_generated_headers := $(patsubst %.pb$(my_proto_source_suffix),%.pb.h, $(proto_generated_sources))
@@ -673,7 +675,7 @@
ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined
$(proto_generated_sources): PRIVATE_PROTO_INCLUDES := $(TOP)
$(proto_generated_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS) $(my_protoc_flags)
-$(proto_generated_sources): $(proto_generated_sources_dir)/%.pb$(my_proto_source_suffix): %.proto $(PROTOC)
+$(proto_generated_sources): $(proto_generated_sources_dir)/%.pb$(my_proto_source_suffix): %.proto $(my_protoc_deps) $(PROTOC)
$(transform-proto-to-cc)
# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
diff --git a/core/config.mk b/core/config.mk
index 39c58da..4e82476 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -512,6 +512,10 @@
BREAKPAD_GENERATE_SYMBOLS := false
endif
PROTOC := $(HOST_OUT_EXECUTABLES)/aprotoc$(HOST_EXECUTABLE_SUFFIX)
+NANOPB_SRCS := external/nanopb-c/generator/protoc-gen-nanopb \
+ $(wildcard external/nanopb-c/generator/*.py \
+ external/nanopb-c/generator/google/*.py \
+ external/nanopb-c/generator/proto/*.py)
DBUS_GENERATOR := $(HOST_OUT_EXECUTABLES)/dbus-binding-generator
MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX)
MINIGZIP := $(HOST_OUT_EXECUTABLES)/minigzip$(HOST_EXECUTABLE_SUFFIX)