Pass StopBefore as an argument to RunBlueprint.
Its value is a function of the call site, so it doesn't make a lot of
sense to plumb it through the configuration.
Test: Presubmits.
Change-Id: If928b34de075969fd42932212ce9187808cbdf86
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index 2cad785..684160f 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -101,12 +101,9 @@
return android.NewNameResolver(exportFilter)
}
-func newContext(configuration android.Config, prepareBuildActions bool) *android.Context {
+func newContext(configuration android.Config) *android.Context {
ctx := android.NewContext(configuration)
ctx.Register()
- if !prepareBuildActions {
- configuration.SetStopBefore(bootstrap.StopBeforePrepareBuildActions)
- }
ctx.SetNameInterface(newNameResolver(configuration))
ctx.SetAllowMissingDependencies(configuration.AllowMissingDependencies())
return ctx
@@ -130,8 +127,7 @@
var firstArgs, secondArgs bootstrap.Args
firstArgs = cmdlineArgs
- configuration.SetStopBefore(bootstrap.StopBeforeWriteNinja)
- bootstrap.RunBlueprint(firstArgs, firstCtx.Context, configuration)
+ bootstrap.RunBlueprint(firstArgs, bootstrap.StopBeforeWriteNinja, firstCtx.Context, configuration)
// Invoke bazel commands and save results for second pass.
if err := configuration.BazelContext.InvokeBazel(); err != nil {
@@ -145,8 +141,8 @@
fmt.Fprintf(os.Stderr, "%s", err)
os.Exit(1)
}
- secondCtx := newContext(secondConfig, true)
- ninjaDeps := bootstrap.RunBlueprint(secondArgs, secondCtx.Context, secondConfig)
+ secondCtx := newContext(secondConfig)
+ ninjaDeps := bootstrap.RunBlueprint(secondArgs, bootstrap.DoEverything, secondCtx.Context, secondConfig)
ninjaDeps = append(ninjaDeps, extraNinjaDeps...)
globListFiles := writeBuildGlobsNinjaFile(secondCtx.SrcDir(), configuration.SoongOutDir(), secondCtx.Globs, configuration)
@@ -168,9 +164,9 @@
}
func runSoongDocs(configuration android.Config) {
- ctx := newContext(configuration, false)
+ ctx := newContext(configuration)
soongDocsArgs := cmdlineArgs
- bootstrap.RunBlueprint(soongDocsArgs, ctx.Context, configuration)
+ bootstrap.RunBlueprint(soongDocsArgs, bootstrap.StopBeforePrepareBuildActions, ctx.Context, configuration)
if err := writeDocs(ctx, configuration, docFile); err != nil {
fmt.Fprintf(os.Stderr, "%s", err)
os.Exit(1)
@@ -226,7 +222,14 @@
generateQueryView := bazelQueryViewDir != ""
blueprintArgs := cmdlineArgs
- prepareBuildActions := !generateQueryView && moduleGraphFile == ""
+
+ var stopBefore bootstrap.StopBefore
+ if !generateQueryView && moduleGraphFile == "" {
+ stopBefore = bootstrap.DoEverything
+ } else {
+ stopBefore = bootstrap.StopBeforePrepareBuildActions
+ }
+
if bazelConversionRequested {
// Run the alternate pipeline of bp2build mutators and singleton to convert
// Blueprint to BUILD files before everything else.
@@ -234,11 +237,11 @@
return bp2buildMarker
}
- ctx := newContext(configuration, prepareBuildActions)
+ ctx := newContext(configuration)
if mixedModeBuild {
runMixedModeBuild(configuration, ctx, extraNinjaDeps)
} else {
- ninjaDeps := bootstrap.RunBlueprint(blueprintArgs, ctx.Context, configuration)
+ ninjaDeps := bootstrap.RunBlueprint(blueprintArgs, stopBefore, ctx.Context, configuration)
ninjaDeps = append(ninjaDeps, extraNinjaDeps...)
globListFiles := writeBuildGlobsNinjaFile(ctx.SrcDir(), configuration.SoongOutDir(), ctx.Globs, configuration)
@@ -479,14 +482,11 @@
extraNinjaDeps = append(extraNinjaDeps, modulePaths...)
- // No need to generate Ninja build rules/statements from Modules and Singletons.
- configuration.SetStopBefore(bootstrap.StopBeforePrepareBuildActions)
-
// Run the loading and analysis pipeline to prepare the graph of regular
// Modules parsed from Android.bp files, and the BazelTargetModules mapped
// from the regular Modules.
blueprintArgs := cmdlineArgs
- ninjaDeps := bootstrap.RunBlueprint(blueprintArgs, bp2buildCtx.Context, configuration)
+ ninjaDeps := bootstrap.RunBlueprint(blueprintArgs, bootstrap.StopBeforePrepareBuildActions, bp2buildCtx.Context, configuration)
ninjaDeps = append(ninjaDeps, extraNinjaDeps...)
globListFiles := writeBuildGlobsNinjaFile(bp2buildCtx.SrcDir(), configuration.SoongOutDir(), bp2buildCtx.Globs, configuration)