diff options
author | Ricardo Cerqueira <ricardo@cyngn.com> | 2016-01-25 16:49:27 +0000 |
---|---|---|
committer | Ricardo Cerqueira <ricardo@cyngn.com> | 2016-01-26 00:17:52 +0000 |
commit | 947c4cdf1c7653b7aacafca38955234a5a33f364 (patch) | |
tree | f18b1f164a0f5790b44890e9b9af61aea434a478 | |
parent | 9be9dd173eb69ac581a78f619b90d027095446d4 (diff) | |
download | replicant_build-947c4cdf1c7653b7aacafca38955234a5a33f364.zip replicant_build-947c4cdf1c7653b7aacafca38955234a5a33f364.tar.gz replicant_build-947c4cdf1c7653b7aacafca38955234a5a33f364.tar.bz2 |
binary: Allow specifying a path for generated proto headers
protobuf compilation defaults to dropping the generated objects and
headers onto a path derived from the origin source path. This poses
a problem with some of our repositories since they're not placed in
their original paths, and may include hard references to pb headers
assuming the original directory.
Typical use of this will be to place a
LOCAL_PROTOC_OUTPUT := <original repo path>
line in the relevant module block (for example, "hardware/ril" for our
"hardware/ril-caf")
Change-Id: Ib9b0cadd47e29a0d2e693b331cfc18e71b048ee5
-rw-r--r-- | core/binary.mk | 15 | ||||
-rw-r--r-- | core/clear_vars.mk | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/core/binary.mk b/core/binary.mk index 4206597..46fd492 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -538,17 +538,32 @@ proto_generated_headers := $(patsubst %.pb$(my_proto_source_suffix),%.pb.h, $(pr proto_generated_objects := $(addprefix $(proto_generated_obj_dir)/, \ $(patsubst %.proto,%.pb.o,$(proto_sources_fullpath))) +define copy-proto-files +$(if $(PRIVATE_PROTOC_OUTPUT), \ + $(eval proto_generated_path := $(dir $(subst $(PRIVATE_PROTOC_INPUT),$(PRIVATE_PROTOC_OUTPUT),$@))) + @mkdir -p $(dir $(proto_generated_path)) + @echo "Protobuf relocation: $@ => $(proto_generated_path)" + @cp -f $@ $(proto_generated_path) ,) +endef + + # Ensure the transform-proto-to-cc rule is only defined once in multilib build. 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): PRIVATE_PROTOC_OUTPUT := $(LOCAL_PROTOC_OUTPUT) +$(proto_generated_sources): PRIVATE_PROTOC_INPUT := $(LOCAL_PATH) $(proto_generated_sources): $(proto_generated_sources_dir)/%.pb$(my_proto_source_suffix): %.proto $(PROTOC) $(transform-proto-to-cc) + $(copy-proto-files) # This is just a dummy rule to make sure gmake doesn't skip updating the dependents. +$(proto_generated_headers): PRIVATE_PROTOC_OUTPUT := $(LOCAL_PROTOC_OUTPUT) +$(proto_generated_headers): PRIVATE_PROTOC_INPUT := $(LOCAL_PATH) $(proto_generated_headers): $(proto_generated_sources_dir)/%.pb.h: $(proto_generated_sources_dir)/%.pb$(my_proto_source_suffix) @echo "Updated header file $@." $(hide) touch $@ + $(copy-proto-files) $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true endif # transform-proto-to-cc rule included only once diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 794e1a9..5c53c9f 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -293,6 +293,8 @@ LOCAL_MODULE_STEM_64:= LOCAL_CLANG_32:= LOCAL_CLANG_64:= +LOCAL_PROTOC_OUTPUT:= + # Include any vendor specific clear_vars.mk file -include $(TOPDIR)vendor/*/build/core/clear_vars.mk |