Add support for LOCAL_EXPORT_*_LIBRARY_HEADERS

Listing a library in any of:

  LOCAL_EXPORT_SHARED_LIBRARY_HEADERS
  LOCAL_EXPORT_STATIC_LIBRARY_HEADERS

will cause the headers exported by that library to be exported from
the current library target as well.

This means that when library A's public headers include headers from
library B, library C which consumes A no longer has to explicitly list
A and B in its LOCAL_SHARED_LIBRARIES for the purpose of picking up B's
headers.

Bug: 27804373
Test: Introduced dependency on libbase to libbinder at the header level.
      Libraries that consume libbinder do not need to explicitly depend
      on libbase.

Change-Id: If69079f058a4a182c5ef5a3c5ba15035570da22d
diff --git a/core/binary.mk b/core/binary.mk
index 89af0a5..63260ab 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -1409,9 +1409,18 @@
 ###########################################################
 export_includes := $(intermediates)/export_includes
 $(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(my_export_c_include_dirs)
+# Headers exported by whole static libraries are also exported by this library.
 export_include_deps := $(strip \
    $(foreach l,$(my_whole_static_libraries), \
      $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
+# Re-export requested headers from shared libraries.
+export_include_deps += $(strip \
+   $(foreach l,$(LOCAL_EXPORT_SHARED_LIBRARY_HEADERS), \
+     $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
+# Re-export requested headers from static libraries.
+export_include_deps += $(strip \
+   $(foreach l,$(LOCAL_EXPORT_STATIC_LIBRARY_HEADERS), \
+     $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
 $(export_includes): PRIVATE_REEXPORTED_INCLUDES := $(export_include_deps)
 # Make sure .pb.h are already generated before any dependent source files get compiled.
 # Similarly, the generated DBus headers need to exist before we export their location.