Merge "Deprecate Snapshot build" into main

This commit is contained in:
Treehugger Robot
2024-04-05 04:59:43 +00:00
committed by Gerrit Code Review
37 changed files with 85 additions and 3853 deletions

View File

@@ -421,126 +421,9 @@ type libraryDecorator struct {
*baseLinker
*baseInstaller
collectedSnapshotHeaders android.Paths
apiListCoverageXmlPath android.ModuleOutPath
}
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 paths {
dir := path.String()
// Skip if dir is for generated headers
if strings.HasPrefix(dir, ctx.Config().OutDir()) {
continue
}
// libeigen wrongly exports the root directory "external/eigen". But only two
// subdirectories "Eigen" and "unsupported" contain exported header files. Even worse
// some of them have no extension. So we need special treatment for libeigen in order
// to glob correctly.
if dir == "external/eigen" {
// Only these two directories contains exported headers.
for _, subdir := range []string{"Eigen", "unsupported/Eigen"} {
globDir := "external/eigen/" + subdir + "/**/*"
glob, err := ctx.GlobWithDeps(globDir, nil)
if err != nil {
ctx.ModuleErrorf("glob of %q failed: %s", globDir, err)
return nil
}
for _, header := range glob {
if strings.HasSuffix(header, "/") {
continue
}
ext := filepath.Ext(header)
if ext != "" && ext != ".h" {
continue
}
ret = append(ret, android.PathForSource(ctx, header))
}
}
continue
}
globDir := dir + "/**/*"
glob, err := ctx.GlobWithDeps(globDir, nil)
if err != nil {
ctx.ModuleErrorf("glob of %q failed: %s", globDir, err)
return nil
}
isLibcxx := strings.HasPrefix(dir, "external/libcxx/include")
for _, header := range glob {
if isLibcxx {
// Glob all files under this special directory, because of C++ headers with no
// extension.
if strings.HasSuffix(header, "/") {
continue
}
} else {
// Filter out only the files with extensions that are headers.
found := false
for _, ext := range HeaderExts {
if strings.HasSuffix(header, ext) {
found = true
break
}
}
if !found {
continue
}
}
ret = append(ret, android.PathForSource(ctx, header))
}
}
return ret
}
func GlobGeneratedHeadersForSnapshot(_ 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
}
// This returns all exported header files, both generated ones and headers from source tree.
// collectHeadersForSnapshot() must be called before calling this.
func (l *libraryDecorator) snapshotHeaders() android.Paths {
if l.collectedSnapshotHeaders == nil {
panic("snapshotHeaders() must be called after collectHeadersForSnapshot()")
}
return l.collectedSnapshotHeaders
}
// linkerProps returns the list of properties structs relevant for this library. (For example, if
// the library is cc_shared_library, then static-library properties are omitted.)
func (library *libraryDecorator) linkerProps() []interface{} {