Invoke queryview from the bootstrap Ninja file.
It used to be invoked from out/soong/build.ninja, which required two
soong_build invocations one after the other (ne to generate
out/soong/build.ninja, one to generate the queryview workspace). This
was slower and required some shell-quoted-in-ninja-quoted-in-Go .
Test: Presubmits.
Change-Id: Idda79c067606663b66e9f94626fa24f3b5af4114
diff --git a/ui/build/config.go b/ui/build/config.go
index 0b93b18..2cd7d55 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -49,6 +49,7 @@
dist bool
jsonModuleGraph bool
bp2build bool
+ queryview bool
skipConfig bool
skipKati bool
skipKatiNinja bool
@@ -643,6 +644,8 @@
c.jsonModuleGraph = true
} else if arg == "bp2build" {
c.bp2build = true
+ } else if arg == "queryview" {
+ c.queryview = true
} else {
if arg == "checkbuild" {
c.checkbuild = true
@@ -720,7 +723,7 @@
return true
}
- if !c.JsonModuleGraph() && !c.Bp2Build() {
+ if !c.JsonModuleGraph() && !c.Bp2Build() && !c.Queryview() {
// Command line was empty, the default Ninja target is built
return true
}
@@ -785,6 +788,10 @@
return shared.JoinPath(c.SoongOutDir(), ".bootstrap/bp2build_workspace_marker")
}
+func (c *configImpl) QueryviewMarkerFile() string {
+ return shared.JoinPath(c.SoongOutDir(), "queryview.marker")
+}
+
func (c *configImpl) ModuleGraphFile() string {
return shared.JoinPath(c.SoongOutDir(), "module-graph.json")
}
@@ -822,6 +829,10 @@
return c.bp2build
}
+func (c *configImpl) Queryview() bool {
+ return c.queryview
+}
+
func (c *configImpl) IsVerbose() bool {
return c.verbose
}
diff --git a/ui/build/soong.go b/ui/build/soong.go
index fef30da..04d106b 100644
--- a/ui/build/soong.go
+++ b/ui/build/soong.go
@@ -142,6 +142,7 @@
bootstrapGlobFile := shared.JoinPath(config.SoongOutDir(), ".bootstrap/build-globs.ninja")
bp2buildGlobFile := shared.JoinPath(config.SoongOutDir(), ".bootstrap/build-globs.bp2build.ninja")
+ queryviewGlobFile := shared.JoinPath(config.SoongOutDir(), ".bootstrap/build-globs.queryview.ninja")
moduleGraphGlobFile := shared.JoinPath(config.SoongOutDir(), ".bootstrap/build-globs.modulegraph.ninja")
// The glob .ninja files are subninja'd. However, they are generated during
@@ -149,6 +150,9 @@
// fail on clean builds
writeEmptyGlobFile(ctx, bootstrapGlobFile)
writeEmptyGlobFile(ctx, bp2buildGlobFile)
+ writeEmptyGlobFile(ctx, queryviewGlobFile)
+ writeEmptyGlobFile(ctx, moduleGraphGlobFile)
+
bootstrapDepFile := shared.JoinPath(config.SoongOutDir(), ".bootstrap/build.ninja.d")
args.RunGoTests = !config.skipSoongTests
@@ -160,7 +164,7 @@
// The primary builder (aka soong_build) will use bootstrapGlobFile as the globFile to generate build.ninja(.d)
// Building soong_build does not require a glob file
// Using "" instead of "<soong_build_glob>.ninja" will ensure that an unused glob file is not written to out/soong/.bootstrap during StagePrimary
- args.Subninjas = []string{bootstrapGlobFile, bp2buildGlobFile}
+ args.Subninjas = []string{bootstrapGlobFile, bp2buildGlobFile, moduleGraphGlobFile, queryviewGlobFile}
args.EmptyNinjaFile = config.EmptyNinjaFile()
args.DelveListen = os.Getenv("SOONG_DELVE")
@@ -206,6 +210,22 @@
Args: bp2buildArgs,
}
+ queryviewArgs := []string{
+ "--bazel_queryview_dir", filepath.Join(config.SoongOutDir(), "queryview"),
+ "--globListDir", "queryview",
+ "--globFile", queryviewGlobFile,
+ }
+
+ queryviewArgs = append(queryviewArgs, commonArgs...)
+ queryviewArgs = append(queryviewArgs, environmentArgs(config, ".queryview")...)
+ queryviewArgs = append(queryviewArgs, "Android.bp")
+
+ queryviewInvocation := bootstrap.PrimaryBuilderInvocation{
+ Inputs: []string{"Android.bp"},
+ Outputs: []string{config.QueryviewMarkerFile()},
+ Args: queryviewArgs,
+ }
+
moduleGraphArgs := []string{
"--module_graph_file", config.ModuleGraphFile(),
"--globListDir", "modulegraph",
@@ -226,6 +246,7 @@
bp2buildInvocation,
mainSoongBuildInvocation,
moduleGraphInvocation,
+ queryviewInvocation,
}
blueprintCtx := blueprint.NewContext()
@@ -361,6 +382,10 @@
targets = append(targets, config.Bp2BuildMarkerFile())
}
+ if config.Queryview() {
+ targets = append(targets, config.QueryviewMarkerFile())
+ }
+
if config.SoongBuildInvocationNeeded() {
// This build generates <builddir>/build.ninja, which is used later by build/soong/ui/build/build.go#Build().
targets = append(targets, config.MainNinjaFile())