Clean include directory paths

To remove '../' and other strangeness from compiler arguments, which run
into problems with remote execution:

  Android.mk: LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/bar/..
  foo.c: #include "foo.h"
  include/foo.h

In this case, we'll send foo.c and include/foo.h, but include/bar may be
empty, and not exist on the remote server. So while the file is there,
you may not be able to access it.

There's also a byproduct of removing extra '/' and './' components,
which should be harmless.

Fixes: 144109314
Test: diff build-aosp_arm.ninja before/after; scan diffs
Test: treehugger
Change-Id: Id2eceba76fbf9b1524487e82cb5c8903c815e45f
diff --git a/core/binary.mk b/core/binary.mk
index 604315e..e4805cd 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -1296,6 +1296,8 @@
   my_c_includes += $(JNI_H_INCLUDE)
 endif
 
+my_c_includes := $(foreach inc,$(my_c_includes),$(call clean-path,$(inc)))
+
 my_outside_includes := $(filter-out $(OUT_DIR)/%,$(filter /%,$(my_c_includes)))
 ifneq ($(my_outside_includes),)
 $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): C_INCLUDES must be under the source or output directories: $(my_outside_includes))
@@ -1803,7 +1805,7 @@
 
 ifneq ($(strip $(my_export_c_include_dirs)$(export_include_deps)),)
   EXPORTS_LIST := $(EXPORTS_LIST) $(intermediates)
-  EXPORTS.$(intermediates).FLAGS := $(foreach d,$(my_export_c_include_dirs),-I $(d))
+  EXPORTS.$(intermediates).FLAGS := $(foreach d,$(my_export_c_include_dirs),-I $(call clean-path,$(d)))
   EXPORTS.$(intermediates).REEXPORT := $(export_include_deps)
   EXPORTS.$(intermediates).DEPS := $(my_export_c_include_deps) $(my_generated_sources) $(LOCAL_EXPORT_C_INCLUDE_DEPS)
 endif