From 273af7f3aa02615a4b57e95bc06bcfd2953c3360 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Thu, 3 Nov 2016 15:53:42 -0700 Subject: [PATCH] Add export_include_dirs to the local include path Bug: 32641232 Test: ./soong builds compared before/after Change-Id: If417a9f2278f42ffa524fccfd34f2b01a8cc9fb5 --- cc/compiler.go | 11 +++++++---- cc/library.go | 12 +++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/cc/compiler.go b/cc/compiler.go index 7e79dfa0a..c1040dd0c 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -150,11 +150,14 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag flags.YaccFlags = append(flags.YaccFlags, esc(compiler.Properties.Yaccflags)...) // Include dir cflags - rootIncludeDirs := android.PathsForSource(ctx, compiler.Properties.Include_dirs) localIncludeDirs := android.PathsForModuleSrc(ctx, compiler.Properties.Local_include_dirs) - flags.GlobalFlags = append(flags.GlobalFlags, - includeDirsToFlags(localIncludeDirs), - includeDirsToFlags(rootIncludeDirs)) + if len(localIncludeDirs) > 0 { + flags.GlobalFlags = append(flags.GlobalFlags, includeDirsToFlags(localIncludeDirs)) + } + rootIncludeDirs := android.PathsForSource(ctx, compiler.Properties.Include_dirs) + if len(rootIncludeDirs) > 0 { + flags.GlobalFlags = append(flags.GlobalFlags, includeDirsToFlags(rootIncludeDirs)) + } if !ctx.noDefaultCompilerFlags() { if !ctx.sdk() || ctx.Host() { diff --git a/cc/library.go b/cc/library.go index 73efb9eab..5fb522a56 100644 --- a/cc/library.go +++ b/cc/library.go @@ -74,7 +74,8 @@ type LibraryProperties struct { 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 @@ func (library *libraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Fla 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