From 1cda3fd3e4b1cbd4f9fed8ac59faa1be1954edff Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 16 Jan 2020 10:32:35 -0800 Subject: [PATCH] Fix primary builder reruns caused by globs Globs produce a filelist using restat rules to avoid primary builder reruns. On the first execution of the primary builder the filelists are written directly by the primary builder, so that the second execution can restat them all but avoid rerunning the primary builder. This wasn't working because the glob filelists were written after the build.ninja file, but the build.ninja file depends on the filelists. Switching the order avoids the extra rerun. Test: m nothing && m nothing Change-Id: Ia8e0924598220d4ff34235907a8de2e3e03632df --- bootstrap/command.go | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/bootstrap/command.go b/bootstrap/command.go index e56c6c1..1e3b2fe 100644 --- a/bootstrap/command.go +++ b/bootstrap/command.go @@ -194,25 +194,6 @@ func Main(ctx *blueprint.Context, config interface{}, extraNinjaFileDeps ...stri out = ioutil.Discard } - err = ctx.WriteBuildFile(out) - if err != nil { - fatalf("error writing Ninja file contents: %s", err) - } - - if buf != nil { - err = buf.Flush() - if err != nil { - fatalf("error flushing Ninja file contents: %s", err) - } - } - - if f != nil { - err = f.Close() - if err != nil { - fatalf("error closing Ninja file: %s", err) - } - } - if globFile != "" { buffer, errs := generateGlobNinjaFile(ctx.Globs) if len(errs) > 0 { @@ -232,6 +213,25 @@ func Main(ctx *blueprint.Context, config interface{}, extraNinjaFileDeps ...stri } } + err = ctx.WriteBuildFile(out) + if err != nil { + fatalf("error writing Ninja file contents: %s", err) + } + + if buf != nil { + err = buf.Flush() + if err != nil { + fatalf("error flushing Ninja file contents: %s", err) + } + } + + if f != nil { + err = f.Close() + if err != nil { + fatalf("error closing Ninja file: %s", err) + } + } + if c, ok := config.(ConfigRemoveAbandonedFilesUnder); ok { under, except := c.RemoveAbandonedFilesUnder() err := removeAbandonedFilesUnder(ctx, bootstrapConfig, SrcDir, under, except) -- GitLab