Stop writing depfiles from Glob singleton

This makes a minimal difference on my AOSP tree (which is on a fast NVME
drive), but it saves ~10-15% of the time in our primary builder
(soong_build) on larger trees on slower drives.

We're always going to run the glob tool at least once outside of the
primary builder, and ninja only loads depfiles created after running the
tool, so this should be a no-op change.

We still need to write the list file (if it has changed), since that's
the file we're adding as a dependency of the primary builder, so the
effective timestamp must be earlier than the build.ninja timestamp.

Change-Id: I872b7581da50e7f2089daa7e248ca05b6703f019
This commit is contained in:
Dan Willemsen 2020-06-24 13:30:26 -07:00
parent 2c0cd0ac8d
commit 55252655d2

View file

@ -21,7 +21,6 @@ import (
"strings"
"github.com/google/blueprint"
"github.com/google/blueprint/deptools"
"github.com/google/blueprint/pathtools"
)
@ -130,15 +129,18 @@ func (s *globSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
if s.writeRule {
depFile := fileListFile + ".d"
// We need to write the file list here so that it has an older modified date
// than the build.ninja (otherwise we'd run the primary builder twice on
// every new glob)
//
// We don't need to write the depfile because we're guaranteed that ninja
// will run the command at least once (to record it into the ninja_log), so
// the depfile will be loaded from that execution.
fileList := strings.Join(g.Files, "\n") + "\n"
err := pathtools.WriteFileIfChanged(absolutePath(fileListFile), []byte(fileList), 0666)
if err != nil {
panic(fmt.Errorf("error writing %s: %s", fileListFile, err))
}
err = deptools.WriteDepFile(absolutePath(depFile), fileListFile, g.Deps)
if err != nil {
panic(fmt.Errorf("error writing %s: %s", depFile, err))
}
GlobFile(ctx, g.Pattern, g.Excludes, fileListFile, depFile)
} else {