Capture snapshot headers in parallel
VNDK and vendor snapshot singleton work in a single thread, so globbing
in singleton results in ridiculus running time. Moving codes to
GenerateAndroidBuildActions to reduce running time.
Bug: 150406226
Test: VNDK_SNAPSHOT_BUILD_ARTIFACTS=true m dist vndk vendor-snapshot
Test: vendorSnapshotSingleton build time became 0.56s (from 10s)
Test: build.ninja building time became 1m11s (from 1m21s)
Change-Id: I4a081eef5847c62ca00280ca426f5b4e10f87b59
diff --git a/cc/snapshot_utils.go b/cc/snapshot_utils.go
index 73388ce..4012def 100644
--- a/cc/snapshot_utils.go
+++ b/cc/snapshot_utils.go
@@ -14,8 +14,6 @@
package cc
import (
- "strings"
-
"android/soong/android"
)
@@ -26,6 +24,8 @@
type snapshotLibraryInterface interface {
exportedFlagsProducer
libraryInterface
+ collectHeadersForSnapshot(ctx android.ModuleContext)
+ snapshotHeaders() android.Paths
}
var _ snapshotLibraryInterface = (*prebuiltLibraryLinker)(nil)
@@ -58,49 +58,13 @@
return snapshot, found
}
-func exportedHeaders(ctx android.SingletonContext, l exportedFlagsProducer) android.Paths {
- var 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(l.exportedDirs(), l.exportedSystemDirs()...) {
- dir := path.String()
- // Skip if dir is for generated headers
- if strings.HasPrefix(dir, android.PathForOutput(ctx).String()) {
- continue
- }
- exts := headerExts
- // 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 {
- ctx.Errorf("%#v\n", err)
- return nil
- }
- for _, header := range glob {
- if strings.HasSuffix(header, "/") {
- continue
- }
- ret = append(ret, android.PathForSource(ctx, header))
- }
- }
+func isSnapshotAware(ctx android.ModuleContext, m *Module) bool {
+ if _, _, ok := isVndkSnapshotLibrary(ctx.DeviceConfig(), m); ok {
+ return ctx.Config().VndkSnapshotBuildArtifacts()
+ } else if isVendorSnapshotModule(m, ctx.ModuleDir()) {
+ return true
}
-
- // Collect generated headers
- for _, header := range append(l.exportedGeneratedHeaders(), l.exportedDeps()...) {
- // TODO(b/148123511): remove exportedDeps after cleaning up genrule
- if strings.HasSuffix(header.Base(), "-phony") {
- continue
- }
- ret = append(ret, header)
- }
-
- return ret
+ return false
}
func copyFile(ctx android.SingletonContext, path android.Path, out string) android.OutputPath {