Handle dependencies with export_generated_headers

This sets up the proper dependencies within Soong by adding the imported
dependencies into GeneratedHeaders, and re-exporting them as necessary.
It also exports them to Make using the new LOCAL_EXPORT_C_INCLUDE_DEPS.

Bug: 31742855
Test: Inspection, build hardware/interfaces (pending)
Change-Id: I6a10ceec377a97966baa9d4876b90fcda391dd01
This commit is contained in:
Dan Willemsen 2016-09-29 12:13:36 -07:00
parent 03ce63eaa6
commit 847dcc7d2a
3 changed files with 22 additions and 1 deletions

View file

@ -100,6 +100,10 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An
if len(exportedIncludes) > 0 { if len(exportedIncludes) > 0 {
fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DIRS :=", strings.Join(exportedIncludes, " ")) fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DIRS :=", strings.Join(exportedIncludes, " "))
} }
exportedIncludeDeps := library.exportedFlagsDeps()
if len(exportedIncludeDeps) > 0 {
fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DEPS :=", strings.Join(exportedIncludeDeps.Strings(), " "))
}
fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext()) fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext())

View file

@ -80,6 +80,7 @@ type PathDeps struct {
GeneratedHeaders android.Paths GeneratedHeaders android.Paths
Flags, ReexportedFlags []string Flags, ReexportedFlags []string
ReexportedFlagsDeps android.Paths
CrtBegin, CrtEnd android.OptionalPath CrtBegin, CrtEnd android.OptionalPath
} }
@ -760,6 +761,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
depPaths.Flags = append(depPaths.Flags, flags) depPaths.Flags = append(depPaths.Flags, flags)
if tag == genHeaderExportDepTag { if tag == genHeaderExportDepTag {
depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags) depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags)
depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps,
genRule.GeneratedSourceFiles()...)
} }
} else { } else {
ctx.ModuleErrorf("module %q is not a genrule", name) ctx.ModuleErrorf("module %q is not a genrule", name)
@ -799,10 +802,13 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
if t, ok := tag.(dependencyTag); ok && t.library { if t, ok := tag.(dependencyTag); ok && t.library {
if i, ok := cc.linker.(exportedFlagsProducer); ok { if i, ok := cc.linker.(exportedFlagsProducer); ok {
flags := i.exportedFlags() flags := i.exportedFlags()
deps := i.exportedFlagsDeps()
depPaths.Flags = append(depPaths.Flags, flags...) depPaths.Flags = append(depPaths.Flags, flags...)
depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, deps...)
if t.reexportFlags { if t.reexportFlags {
depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...) depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...)
depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, deps...)
} }
} }

View file

@ -118,6 +118,7 @@ type flagExporter struct {
Properties FlagExporterProperties Properties FlagExporterProperties
flags []string flags []string
flagsDeps android.Paths
} }
func (f *flagExporter) exportIncludes(ctx ModuleContext, inc string) { func (f *flagExporter) exportIncludes(ctx ModuleContext, inc string) {
@ -131,12 +132,21 @@ func (f *flagExporter) reexportFlags(flags []string) {
f.flags = append(f.flags, flags...) f.flags = append(f.flags, flags...)
} }
func (f *flagExporter) reexportDeps(deps android.Paths) {
f.flagsDeps = append(f.flagsDeps, deps...)
}
func (f *flagExporter) exportedFlags() []string { func (f *flagExporter) exportedFlags() []string {
return f.flags return f.flags
} }
func (f *flagExporter) exportedFlagsDeps() android.Paths {
return f.flagsDeps
}
type exportedFlagsProducer interface { type exportedFlagsProducer interface {
exportedFlags() []string exportedFlags() []string
exportedFlagsDeps() android.Paths
} }
var _ exportedFlagsProducer = (*flagExporter)(nil) var _ exportedFlagsProducer = (*flagExporter)(nil)
@ -445,6 +455,7 @@ func (library *libraryDecorator) link(ctx ModuleContext,
library.exportIncludes(ctx, "-I") library.exportIncludes(ctx, "-I")
library.reexportFlags(deps.ReexportedFlags) library.reexportFlags(deps.ReexportedFlags)
library.reexportDeps(deps.ReexportedFlagsDeps)
return out return out
} }