From 490859563413ef331bf63233d43b8a61d73e0aa8 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Tue, 6 May 2014 13:03:32 -0700 Subject: [PATCH] Automatically export generated .pb.h files. - Automatically export the include path of the generated .pb.h files - Set up the dependency to make sure the .pb.h files get generated before any dependent c/c++ files get compiled. With this change, any module that links a proto library doesn't need any extra setup. Bug: 14563418 Change-Id: Iea7d19e9d8dce8e7d479c386b7a6151a95a0a0df --- core/binary.mk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/binary.mk b/core/binary.mk index f0b3162a5..d5709cac8 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -452,6 +452,9 @@ proto_generated_obj_dir := $(intermediates)/proto proto_generated_objects := $(addprefix $(proto_generated_obj_dir)/, \ $(patsubst %.proto,%.pb.o,$(proto_sources_fullpath))) +# Auto-export the generated proto source dir. +LOCAL_EXPORT_C_INCLUDE_DIRS += $(proto_generated_cc_sources_dir) + # 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_cc_sources): PRIVATE_PROTO_INCLUDES := $(TOP) @@ -918,7 +921,8 @@ $(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets) ########################################################### export_includes := $(intermediates)/export_includes $(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS) -$(export_includes) : $(LOCAL_MODULE_MAKEFILE) +# Make sure .pb.h are already generated before any dependent source files get compiled. +$(export_includes) : $(LOCAL_MODULE_MAKEFILE) $(proto_generated_headers) @echo Export includes file: $< -- $@ $(hide) mkdir -p $(dir $@) && rm -f $@ ifdef LOCAL_EXPORT_C_INCLUDE_DIRS -- 2.11.0