Build system support to export include paths

Bug: 5573756
With this change, we can set LOCAL_EXPORT_C_INCLUDE_DIRS in the module
definition to export include dir paths.
Paths in LOCAL_EXPORT_C_INCLUDE_DIRS should be relative to the top dir
of the source tree.
If a library (shared or static) exports some include paths, any module
using it will import the include paths and add them to the compiler
command line.

Change-Id: I49aabc589d2cf214044d13ccd5532ef68209adf0
diff --git a/core/prebuilt.mk b/core/prebuilt.mk
index 54a7fa9..0c46341 100644
--- a/core/prebuilt.mk
+++ b/core/prebuilt.mk
@@ -27,6 +27,14 @@
   OVERRIDE_BUILT_MODULE_PATH := $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)
 endif
 
+# Deal with the OSX library timestamp issue when installing
+# a prebuilt simulator library.
+ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
+  prebuilt_module_is_a_library := true
+else
+  prebuilt_module_is_a_library :=
+endif
+
 ifeq ($(LOCAL_STRIP_MODULE),true)
   ifdef LOCAL_IS_HOST_MODULE
     $(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH))
@@ -42,14 +50,13 @@
 else
   include $(BUILD_SYSTEM)/base_rules.mk
   built_module := $(LOCAL_BUILT_MODULE)
-endif
 
-# Deal with the OSX library timestamp issue when installing
-# a prebuilt simulator library.
-ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
-  prebuilt_module_is_a_library := true
-else
-  prebuilt_module_is_a_library :=
+ifdef prebuilt_module_is_a_library
+# Create a dummy export_includes.
+$(intermediates)/export_includes:
+	$(hide) mkdir -p $(dir $@) && rm -f $@
+	$(hide) touch $@
+endif
 endif
 
 PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
@@ -115,6 +122,13 @@
 else
 $(built_module) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ACP)
 	$(transform-prebuilt-to-target)
+ifneq ($(prebuilt_module_is_a_library),)
+  ifneq ($(LOCAL_IS_HOST_MODULE),)
+	$(transform-host-ranlib-copy-hack)
+  else
+	$(transform-ranlib-copy-hack)
+  endif
+endif
 endif
 endif
 
@@ -135,11 +149,3 @@
 # make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
 $(built_module) : $(common_javalib_jar)
 endif # TARGET JAVA_LIBRARIES
-
-ifneq ($(prebuilt_module_is_a_library),)
-  ifneq ($(LOCAL_IS_HOST_MODULE),)
-	$(transform-host-ranlib-copy-hack)
-  else
-	$(transform-ranlib-copy-hack)
-  endif
-endif