Merge "Export cc vendor functions for usage by rust."

This commit is contained in:
Ivan Lozano
2021-06-03 15:50:36 +00:00
committed by Gerrit Code Review
12 changed files with 276 additions and 249 deletions

View File

@@ -619,20 +619,14 @@ func (handler *staticLibraryBazelHandler) generateBazelBuildActions(ctx android.
return ok
}
// collectHeadersForSnapshot collects all exported headers from library.
// It globs header files in the source tree for exported include directories,
// and tracks generated header files separately.
//
// This is to be called from GenerateAndroidBuildActions, and then collected
// header files can be retrieved by snapshotHeaders().
func (l *libraryDecorator) collectHeadersForSnapshot(ctx android.ModuleContext) {
func GlobHeadersForSnapshot(ctx android.ModuleContext, paths android.Paths) android.Paths {
ret := android.Paths{}
// Headers in the source tree should be globbed. On the contrast, generated headers
// can't be globbed, and they should be manually collected.
// So, we first filter out intermediate directories (which contains generated headers)
// from exported directories, and then glob headers under remaining directories.
for _, path := range append(android.CopyOfPaths(l.flagExporter.dirs), l.flagExporter.systemDirs...) {
for _, path := range paths {
dir := path.String()
// Skip if dir is for generated headers
if strings.HasPrefix(dir, android.PathForOutput(ctx).String()) {
@@ -648,7 +642,7 @@ func (l *libraryDecorator) collectHeadersForSnapshot(ctx android.ModuleContext)
glob, err := ctx.GlobWithDeps("external/eigen/"+subdir+"/**/*", nil)
if err != nil {
ctx.ModuleErrorf("glob failed: %#v", err)
return
return nil
}
for _, header := range glob {
if strings.HasSuffix(header, "/") {
@@ -666,7 +660,7 @@ func (l *libraryDecorator) collectHeadersForSnapshot(ctx android.ModuleContext)
glob, err := ctx.GlobWithDeps(dir+"/**/*", nil)
if err != nil {
ctx.ModuleErrorf("glob failed: %#v", err)
return
return nil
}
isLibcxx := strings.HasPrefix(dir, "external/libcxx/include")
for _, header := range glob {
@@ -679,7 +673,7 @@ func (l *libraryDecorator) collectHeadersForSnapshot(ctx android.ModuleContext)
} else {
// Filter out only the files with extensions that are headers.
found := false
for _, ext := range headerExts {
for _, ext := range HeaderExts {
if strings.HasSuffix(header, ext) {
found = true
break
@@ -692,15 +686,38 @@ func (l *libraryDecorator) collectHeadersForSnapshot(ctx android.ModuleContext)
ret = append(ret, android.PathForSource(ctx, header))
}
}
return ret
}
// Collect generated headers
for _, header := range append(android.CopyOfPaths(l.flagExporter.headers), l.flagExporter.deps...) {
func GlobGeneratedHeadersForSnapshot(ctx android.ModuleContext, paths android.Paths) android.Paths {
ret := android.Paths{}
for _, header := range paths {
// TODO(b/148123511): remove exportedDeps after cleaning up genrule
if strings.HasSuffix(header.Base(), "-phony") {
continue
}
ret = append(ret, header)
}
return ret
}
// collectHeadersForSnapshot collects all exported headers from library.
// It globs header files in the source tree for exported include directories,
// and tracks generated header files separately.
//
// This is to be called from GenerateAndroidBuildActions, and then collected
// header files can be retrieved by snapshotHeaders().
func (l *libraryDecorator) collectHeadersForSnapshot(ctx android.ModuleContext) {
ret := android.Paths{}
// Headers in the source tree should be globbed. On the contrast, generated headers
// can't be globbed, and they should be manually collected.
// So, we first filter out intermediate directories (which contains generated headers)
// from exported directories, and then glob headers under remaining directories.
ret = append(ret, GlobHeadersForSnapshot(ctx, append(android.CopyOfPaths(l.flagExporter.dirs), l.flagExporter.systemDirs...))...)
// Collect generated headers
ret = append(ret, GlobGeneratedHeadersForSnapshot(ctx, append(android.CopyOfPaths(l.flagExporter.headers), l.flagExporter.deps...))...)
l.collectedSnapshotHeaders = ret
}