Merge remote-tracking branch 'upstream/master' into pull-upstream-3

* upstream/master:
  Remove unnecessary depFile parameter from GlobFile
  Create early-exit hook StopBeforeWriteNinja

Test: m nothing
Test: Treehugger
Change-Id: I0f9ed211f99c2e4d3d208237a7b00f7cd9cd0af4
This commit is contained in:
Chris Parsons 2020-11-10 16:12:38 -05:00
commit e5dbb9140d
3 changed files with 11 additions and 8 deletions

View file

@ -179,6 +179,12 @@ func Main(ctx *blueprint.Context, config interface{}, extraNinjaFileDeps ...stri
}
deps = append(deps, extraDeps...)
if c, ok := config.(ConfigStopBefore); ok {
if c.StopBefore() == StopBeforeWriteNinja {
return
}
}
const outFilePermissions = 0666
var out io.Writer
var f *os.File

View file

@ -87,6 +87,7 @@ type StopBefore int
const (
StopBeforePrepareBuildActions StopBefore = 1
StopBeforeWriteNinja StopBefore = 2
)
type ConfigStopBefore interface {

View file

@ -64,11 +64,9 @@ type GlobFileContext interface {
// GlobFile creates a rule to write to fileListFile a list of the files that match the specified
// pattern but do not match any of the patterns specified in excludes. The file will include
// appropriate dependencies written to depFile to regenerate the file if and only if the list of
// matching files has changed.
func GlobFile(ctx GlobFileContext, pattern string, excludes []string,
fileListFile, depFile string) {
// appropriate dependencies to regenerate the file if and only if the list of matching files has
// changed.
func GlobFile(ctx GlobFileContext, pattern string, excludes []string, fileListFile string) {
ctx.Build(pctx, blueprint.BuildParams{
Rule: GlobRule,
Outputs: []string{fileListFile},
@ -127,8 +125,6 @@ func (s *globSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
fileListFile := filepath.Join(BuildDir, ".glob", g.Name)
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)
@ -142,7 +138,7 @@ func (s *globSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
panic(fmt.Errorf("error writing %s: %s", fileListFile, err))
}
GlobFile(ctx, g.Pattern, g.Excludes, fileListFile, depFile)
GlobFile(ctx, g.Pattern, g.Excludes, fileListFile)
} else {
// Make build.ninja depend on the fileListFile
ctx.AddNinjaFileDeps(fileListFile)