Merge "Change exportedDirs and exportedSystemDirs from []string to android.Paths"

This commit is contained in:
Treehugger Robot
2019-10-28 02:24:41 +00:00
committed by Gerrit Code Review
7 changed files with 39 additions and 38 deletions

View File

@@ -153,10 +153,10 @@ func makeOverrideModuleNames(ctx AndroidMkContext, overrides []string) []string
func (library *libraryDecorator) androidMkWriteExportedFlags(w io.Writer) { func (library *libraryDecorator) androidMkWriteExportedFlags(w io.Writer) {
exportedFlags := library.exportedFlags() exportedFlags := library.exportedFlags()
for _, dir := range library.exportedDirs() { for _, dir := range library.exportedDirs() {
exportedFlags = append(exportedFlags, "-I"+dir) exportedFlags = append(exportedFlags, "-I"+dir.String())
} }
for _, dir := range library.exportedSystemDirs() { for _, dir := range library.exportedSystemDirs() {
exportedFlags = append(exportedFlags, "-isystem "+dir) exportedFlags = append(exportedFlags, "-isystem "+dir.String())
} }
if len(exportedFlags) > 0 { if len(exportedFlags) > 0 {
fmt.Fprintln(w, "LOCAL_EXPORT_CFLAGS :=", strings.Join(exportedFlags, " ")) fmt.Fprintln(w, "LOCAL_EXPORT_CFLAGS :=", strings.Join(exportedFlags, " "))

View File

@@ -123,10 +123,10 @@ type PathDeps struct {
GeneratedHeaders android.Paths GeneratedHeaders android.Paths
Flags []string Flags []string
IncludeDirs []string IncludeDirs android.Paths
SystemIncludeDirs []string SystemIncludeDirs android.Paths
ReexportedDirs []string ReexportedDirs android.Paths
ReexportedSystemDirs []string ReexportedSystemDirs android.Paths
ReexportedFlags []string ReexportedFlags []string
ReexportedDeps android.Paths ReexportedDeps android.Paths
@@ -1096,10 +1096,10 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
flags.GlobalFlags = append(flags.GlobalFlags, deps.Flags...) flags.GlobalFlags = append(flags.GlobalFlags, deps.Flags...)
for _, dir := range deps.IncludeDirs { for _, dir := range deps.IncludeDirs {
flags.GlobalFlags = append(flags.GlobalFlags, "-I"+dir) flags.GlobalFlags = append(flags.GlobalFlags, "-I"+dir.String())
} }
for _, dir := range deps.SystemIncludeDirs { for _, dir := range deps.SystemIncludeDirs {
flags.GlobalFlags = append(flags.GlobalFlags, "-isystem "+dir) flags.GlobalFlags = append(flags.GlobalFlags, "-isystem "+dir.String())
} }
c.flags = flags c.flags = flags
@@ -1725,13 +1725,13 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
if genRule, ok := dep.(genrule.SourceFileGenerator); ok { if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders,
genRule.GeneratedDeps()...) genRule.GeneratedDeps()...)
dirs := genRule.GeneratedHeaderDirs().Strings() dirs := genRule.GeneratedHeaderDirs()
depPaths.IncludeDirs = append(depPaths.IncludeDirs, dirs...) depPaths.IncludeDirs = append(depPaths.IncludeDirs, dirs...)
if depTag == genHeaderExportDepTag { if depTag == genHeaderExportDepTag {
depPaths.ReexportedDirs = append(depPaths.ReexportedDirs, dirs...) depPaths.ReexportedDirs = append(depPaths.ReexportedDirs, dirs...)
depPaths.ReexportedDeps = append(depPaths.ReexportedDeps, genRule.GeneratedDeps()...) depPaths.ReexportedDeps = append(depPaths.ReexportedDeps, genRule.GeneratedDeps()...)
// Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library. // Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library.
c.sabi.Properties.ReexportedIncludes = append(c.sabi.Properties.ReexportedIncludes, dirs...) c.sabi.Properties.ReexportedIncludes = append(c.sabi.Properties.ReexportedIncludes, dirs.Strings()...)
} }
} else { } else {
@@ -1847,7 +1847,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
// -isystem headers are not included since for bionic libraries, abi-filtering is taken care of by version // -isystem headers are not included since for bionic libraries, abi-filtering is taken care of by version
// scripts. // scripts.
c.sabi.Properties.ReexportedIncludes = append( c.sabi.Properties.ReexportedIncludes = append(
c.sabi.Properties.ReexportedIncludes, i.exportedDirs()...) c.sabi.Properties.ReexportedIncludes, i.exportedDirs().Strings()...)
} }
} }
@@ -2021,11 +2021,11 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
// Dedup exported flags from dependencies // Dedup exported flags from dependencies
depPaths.Flags = android.FirstUniqueStrings(depPaths.Flags) depPaths.Flags = android.FirstUniqueStrings(depPaths.Flags)
depPaths.IncludeDirs = android.FirstUniqueStrings(depPaths.IncludeDirs) depPaths.IncludeDirs = android.FirstUniquePaths(depPaths.IncludeDirs)
depPaths.SystemIncludeDirs = android.FirstUniqueStrings(depPaths.SystemIncludeDirs) depPaths.SystemIncludeDirs = android.FirstUniquePaths(depPaths.SystemIncludeDirs)
depPaths.GeneratedHeaders = android.FirstUniquePaths(depPaths.GeneratedHeaders) depPaths.GeneratedHeaders = android.FirstUniquePaths(depPaths.GeneratedHeaders)
depPaths.ReexportedDirs = android.FirstUniqueStrings(depPaths.ReexportedDirs) depPaths.ReexportedDirs = android.FirstUniquePaths(depPaths.ReexportedDirs)
depPaths.ReexportedSystemDirs = android.FirstUniqueStrings(depPaths.ReexportedSystemDirs) depPaths.ReexportedSystemDirs = android.FirstUniquePaths(depPaths.ReexportedSystemDirs)
depPaths.ReexportedFlags = android.FirstUniqueStrings(depPaths.ReexportedFlags) depPaths.ReexportedFlags = android.FirstUniqueStrings(depPaths.ReexportedFlags)
depPaths.ReexportedDeps = android.FirstUniquePaths(depPaths.ReexportedDeps) depPaths.ReexportedDeps = android.FirstUniquePaths(depPaths.ReexportedDeps)

View File

@@ -25,7 +25,7 @@ type kernelHeadersDecorator struct {
func (stub *kernelHeadersDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path { func (stub *kernelHeadersDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path {
if ctx.Device() { if ctx.Device() {
f := &stub.libraryDecorator.flagExporter f := &stub.libraryDecorator.flagExporter
f.reexportSystemDirs(ctx.DeviceConfig().DeviceKernelHeaderDirs()...) f.reexportSystemDirs(android.PathsForSource(ctx, ctx.DeviceConfig().DeviceKernelHeaderDirs())...)
} }
return stub.libraryDecorator.linkStatic(ctx, flags, deps, objs) return stub.libraryDecorator.linkStatic(ctx, flags, deps, objs)
} }

View File

@@ -229,8 +229,8 @@ func LibraryHeaderFactory() android.Module {
type flagExporter struct { type flagExporter struct {
Properties FlagExporterProperties Properties FlagExporterProperties
dirs []string dirs android.Paths
systemDirs []string systemDirs android.Paths
flags []string flags []string
deps android.Paths deps android.Paths
} }
@@ -244,18 +244,18 @@ func (f *flagExporter) exportedIncludes(ctx ModuleContext) android.Paths {
} }
func (f *flagExporter) exportIncludes(ctx ModuleContext) { func (f *flagExporter) exportIncludes(ctx ModuleContext) {
f.dirs = append(f.dirs, f.exportedIncludes(ctx).Strings()...) f.dirs = append(f.dirs, f.exportedIncludes(ctx)...)
} }
func (f *flagExporter) exportIncludesAsSystem(ctx ModuleContext) { func (f *flagExporter) exportIncludesAsSystem(ctx ModuleContext) {
f.systemDirs = append(f.systemDirs, f.exportedIncludes(ctx).Strings()...) f.systemDirs = append(f.systemDirs, f.exportedIncludes(ctx)...)
} }
func (f *flagExporter) reexportDirs(dirs ...string) { func (f *flagExporter) reexportDirs(dirs ...android.Path) {
f.dirs = append(f.dirs, dirs...) f.dirs = append(f.dirs, dirs...)
} }
func (f *flagExporter) reexportSystemDirs(dirs ...string) { func (f *flagExporter) reexportSystemDirs(dirs ...android.Path) {
f.systemDirs = append(f.systemDirs, dirs...) f.systemDirs = append(f.systemDirs, dirs...)
} }
@@ -273,11 +273,11 @@ func (f *flagExporter) reexportDeps(deps ...android.Path) {
f.deps = append(f.deps, deps...) f.deps = append(f.deps, deps...)
} }
func (f *flagExporter) exportedDirs() []string { func (f *flagExporter) exportedDirs() android.Paths {
return f.dirs return f.dirs
} }
func (f *flagExporter) exportedSystemDirs() []string { func (f *flagExporter) exportedSystemDirs() android.Paths {
return f.systemDirs return f.systemDirs
} }
@@ -290,8 +290,8 @@ func (f *flagExporter) exportedDeps() android.Paths {
} }
type exportedFlagsProducer interface { type exportedFlagsProducer interface {
exportedDirs() []string exportedDirs() android.Paths
exportedSystemDirs() []string exportedSystemDirs() android.Paths
exportedFlags() []string exportedFlags() []string
exportedDeps() android.Paths exportedDeps() android.Paths
} }
@@ -958,7 +958,7 @@ func (library *libraryDecorator) link(ctx ModuleContext,
if Bool(library.Properties.Aidl.Export_aidl_headers) { if Bool(library.Properties.Aidl.Export_aidl_headers) {
if library.baseCompiler.hasSrcExt(".aidl") { if library.baseCompiler.hasSrcExt(".aidl") {
dir := android.PathForModuleGen(ctx, "aidl").String() dir := android.PathForModuleGen(ctx, "aidl")
library.reexportDirs(dir) library.reexportDirs(dir)
library.reexportDeps(library.baseCompiler.pathDeps...) // TODO: restrict to aidl deps library.reexportDeps(library.baseCompiler.pathDeps...) // TODO: restrict to aidl deps
} }
@@ -966,25 +966,25 @@ func (library *libraryDecorator) link(ctx ModuleContext,
if Bool(library.Properties.Proto.Export_proto_headers) { if Bool(library.Properties.Proto.Export_proto_headers) {
if library.baseCompiler.hasSrcExt(".proto") { if library.baseCompiler.hasSrcExt(".proto") {
includes := []string{} var includes android.Paths
if flags.proto.CanonicalPathFromRoot { if flags.proto.CanonicalPathFromRoot {
includes = append(includes, flags.proto.SubDir.String()) includes = append(includes, flags.proto.SubDir)
} }
includes = append(includes, flags.proto.Dir.String()) includes = append(includes, flags.proto.Dir)
library.reexportDirs(includes...) library.reexportDirs(includes...)
library.reexportDeps(library.baseCompiler.pathDeps...) // TODO: restrict to proto deps library.reexportDeps(library.baseCompiler.pathDeps...) // TODO: restrict to proto deps
} }
} }
if library.baseCompiler.hasSrcExt(".sysprop") { if library.baseCompiler.hasSrcExt(".sysprop") {
dir := android.PathForModuleGen(ctx, "sysprop", "include").String() dir := android.PathForModuleGen(ctx, "sysprop", "include")
if library.Properties.Sysprop.Platform != nil { if library.Properties.Sysprop.Platform != nil {
isProduct := ctx.ProductSpecific() && !ctx.useVndk() isProduct := ctx.ProductSpecific() && !ctx.useVndk()
isVendor := ctx.useVndk() isVendor := ctx.useVndk()
isOwnerPlatform := Bool(library.Properties.Sysprop.Platform) isOwnerPlatform := Bool(library.Properties.Sysprop.Platform)
if !ctx.inRecovery() && (isProduct || (isOwnerPlatform == isVendor)) { if !ctx.inRecovery() && (isProduct || (isOwnerPlatform == isVendor)) {
dir = android.PathForModuleGen(ctx, "sysprop/public", "include").String() dir = android.PathForModuleGen(ctx, "sysprop/public", "include")
} }
} }

View File

@@ -146,9 +146,9 @@ func (stub *llndkStubDecorator) link(ctx ModuleContext, flags Flags, deps PathDe
} }
if Bool(stub.Properties.Export_headers_as_system) { if Bool(stub.Properties.Export_headers_as_system) {
stub.reexportSystemDirs(genHeaderOutDir.String()) stub.reexportSystemDirs(genHeaderOutDir)
} else { } else {
stub.reexportDirs(genHeaderOutDir.String()) stub.reexportDirs(genHeaderOutDir)
} }
stub.reexportDeps(timestampFiles...) stub.reexportDeps(timestampFiles...)

View File

@@ -515,8 +515,8 @@ func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContex
RelativeInstallPath string `json:",omitempty"` RelativeInstallPath string `json:",omitempty"`
}{} }{}
prop.ExportedFlags = l.exportedFlags() prop.ExportedFlags = l.exportedFlags()
prop.ExportedDirs = l.exportedDirs() prop.ExportedDirs = l.exportedDirs().Strings()
prop.ExportedSystemDirs = l.exportedSystemDirs() prop.ExportedSystemDirs = l.exportedSystemDirs().Strings()
prop.RelativeInstallPath = m.RelativeInstallPath() prop.RelativeInstallPath = m.RelativeInstallPath()
propOut := libOut + ".json" propOut := libOut + ".json"
@@ -575,7 +575,7 @@ func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContex
generatedHeaders = append(generatedHeaders, l.exportedDeps()...) generatedHeaders = append(generatedHeaders, l.exportedDeps()...)
for _, dir := range append(l.exportedDirs(), l.exportedSystemDirs()...) { for _, dir := range append(l.exportedDirs(), l.exportedSystemDirs()...) {
includeDirs[dir] = true includeDirs[dir.String()] = true
} }
}) })

View File

@@ -137,7 +137,8 @@ func (p *vndkPrebuiltLibraryDecorator) link(ctx ModuleContext,
if len(p.properties.Srcs) > 0 && p.shared() { if len(p.properties.Srcs) > 0 && p.shared() {
p.libraryDecorator.exportIncludes(ctx) p.libraryDecorator.exportIncludes(ctx)
p.libraryDecorator.reexportSystemDirs(p.properties.Export_system_include_dirs...) p.libraryDecorator.reexportSystemDirs(
android.PathsForModuleSrc(ctx, p.properties.Export_system_include_dirs)...)
p.libraryDecorator.reexportFlags(p.properties.Export_flags...) p.libraryDecorator.reexportFlags(p.properties.Export_flags...)
// current VNDK prebuilts are only shared libs. // current VNDK prebuilts are only shared libs.
return p.singleSourcePath(ctx) return p.singleSourcePath(ctx)