Add export_include_dirs to the local include path

Bug: 32641232
Test: ./soong builds compared before/after
Change-Id: If417a9f2278f42ffa524fccfd34f2b01a8cc9fb5
diff --git a/cc/library.go b/cc/library.go
index 73efb9e..5fb522a 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -74,7 +74,8 @@
 
 type FlagExporterProperties struct {
 	// list of directories relative to the Blueprints file that will
-	// be added to the include path using -I for any module that links against this module
+	// be added to the include path (using -I) for this module and any module that links
+	// against this module
 	Export_include_dirs []string `android:"arch_variant"`
 }
 
@@ -251,6 +252,15 @@
 	return flags
 }
 
+func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags {
+	exportIncludeDirs := android.PathsForModuleSrc(ctx, library.flagExporter.Properties.Export_include_dirs)
+	if len(exportIncludeDirs) > 0 {
+		flags.GlobalFlags = append(flags.GlobalFlags, includeDirsToFlags(exportIncludeDirs))
+	}
+
+	return library.baseCompiler.compilerFlags(ctx, flags)
+}
+
 func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
 	objs := library.baseCompiler.compile(ctx, flags, deps)
 	library.reuseObjects = objs