Speed up vendor snapshot header globs
The vendor snapshot header globs were repeated 9 times, once for each possible header suffix. Globbing is not a fast operation, so this took 9.68s of CPU time in my AOSP builds. Replace it instead with a single glob, followed by filtering down to the desired header extensions. Test: m checkbuild Change-Id: I9c8f8cdad8cbffc0a42217659a48dd9d676e4e4c
This commit is contained in:
@@ -449,24 +449,38 @@ func (l *libraryDecorator) collectHeadersForSnapshot(ctx android.ModuleContext)
|
|||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
exts := headerExts
|
glob, err := ctx.GlobWithDeps(dir+"/**/*", nil)
|
||||||
// Glob all files under this special directory, because of C++ headers.
|
|
||||||
if strings.HasPrefix(dir, "external/libcxx/include") {
|
|
||||||
exts = []string{""}
|
|
||||||
}
|
|
||||||
for _, ext := range exts {
|
|
||||||
glob, err := ctx.GlobWithDeps(dir+"/**/*"+ext, nil)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ModuleErrorf("glob failed: %#v", err)
|
ctx.ModuleErrorf("glob failed: %#v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, header := range glob {
|
isLibcxx := strings.HasPrefix(dir, "external/libcxx/include")
|
||||||
if strings.HasSuffix(header, "/") {
|
j := 0
|
||||||
|
for i, header := range glob {
|
||||||
|
if isLibcxx {
|
||||||
|
// Glob all files under this special directory, because of C++ headers with no
|
||||||
|
// extension.
|
||||||
|
if !strings.HasSuffix(header, "/") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
ret = append(ret, android.PathForSource(ctx, header))
|
} 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if i != j {
|
||||||
|
glob[j] = glob[i]
|
||||||
|
}
|
||||||
|
j++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect generated headers
|
// Collect generated headers
|
||||||
|
Reference in New Issue
Block a user