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
diff --git a/bootstrap/command.go b/bootstrap/command.go
index dc655e8..c85644e 100644
--- a/bootstrap/command.go
+++ b/bootstrap/command.go
@@ -179,6 +179,12 @@
 	}
 	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
diff --git a/bootstrap/config.go b/bootstrap/config.go
index ace0ae6..d83b042 100644
--- a/bootstrap/config.go
+++ b/bootstrap/config.go
@@ -87,6 +87,7 @@
 
 const (
 	StopBeforePrepareBuildActions StopBefore = 1
+	StopBeforeWriteNinja          StopBefore = 2
 )
 
 type ConfigStopBefore interface {
diff --git a/bootstrap/glob.go b/bootstrap/glob.go
index 207db5b..cf5af72 100644
--- a/bootstrap/glob.go
+++ b/bootstrap/glob.go
@@ -64,11 +64,9 @@
 
 // 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 @@
 		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 @@
 				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)