Allow cc modules to pull in rust includes.

Make sure LinkabeInterfaces can export include dirs to cc modules. This
fixes the Rust implementation and makes sure these are pulled in for cc
modules.

Bug: 144052093
Test: cc module depending on a rust library includes dirs correctly.
Change-Id: I6b5d5e6ab6afb507178b4f2cbdc45f01031dbfe4
This commit is contained in:
Ivan Lozano 2019-11-06 19:15:49 -08:00
parent af60d490ff
commit e0833b1f5c
4 changed files with 14 additions and 5 deletions

View File

@ -501,7 +501,7 @@ func (c *Module) SdkVersion() string {
return String(c.Properties.Sdk_version)
}
func (c *Module) IncludeDirs(ctx android.BaseModuleContext) android.Paths {
func (c *Module) IncludeDirs() android.Paths {
if c.linker != nil {
if library, ok := c.linker.(exportedFlagsProducer); ok {
return library.exportedDirs()
@ -2027,10 +2027,11 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
}
}
depPaths.IncludeDirs = append(depPaths.IncludeDirs, ccDep.IncludeDirs()...)
// Exporting flags only makes sense for cc.Modules
if _, ok := ccDep.(*Module); ok {
if i, ok := ccDep.(*Module).linker.(exportedFlagsProducer); ok {
depPaths.IncludeDirs = append(depPaths.IncludeDirs, i.exportedDirs()...)
depPaths.SystemIncludeDirs = append(depPaths.SystemIncludeDirs, i.exportedSystemDirs()...)
depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, i.exportedDeps()...)
depPaths.Flags = append(depPaths.Flags, i.exportedFlags()...)

View File

@ -13,7 +13,7 @@ type LinkableInterface interface {
OutputFile() android.OptionalPath
IncludeDirs(ctx android.BaseModuleContext) android.Paths
IncludeDirs() android.Paths
SetDepsInLinkOrder([]android.Path)
GetDepsInLinkOrder() []android.Path

View File

@ -78,6 +78,7 @@ type libraryDecorator struct {
MutatedProperties LibraryMutatedProperties
distFile android.OptionalPath
unstrippedOutputFile android.Path
includeDirs android.Paths
}
type libraryInterface interface {
@ -311,6 +312,13 @@ func (library *libraryDecorator) compilerDeps(ctx DepsContext, deps Deps) Deps {
return deps
}
func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags {
flags = library.baseCompiler.compilerFlags(ctx, flags)
if library.shared() || library.static() {
library.includeDirs = append(library.includeDirs, android.PathsForModuleSrc(ctx, library.Properties.Include_dirs)...)
}
return flags
}
func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Path {
var outputFile android.WritablePath

View File

@ -246,10 +246,10 @@ func (mod *Module) CcLibraryInterface() bool {
return false
}
func (mod *Module) IncludeDirs(ctx android.BaseModuleContext) android.Paths {
func (mod *Module) IncludeDirs() android.Paths {
if mod.compiler != nil {
if library, ok := mod.compiler.(*libraryDecorator); ok {
return android.PathsForSource(ctx, library.Properties.Include_dirs)
return library.includeDirs
}
}
panic(fmt.Errorf("IncludeDirs called on non-library module: %q", mod.BaseModuleName()))