Group mixed mode and normal soong build
Mixed mode is a special form of the soong build. They both share common initialization and metrics so they should be grouped together to avoid duplicating that common behavior. Bug: 257650737 Test: m nothing Change-Id: I939b6264f94b69825735dce895132f33401238b6
This commit is contained in:
@@ -165,7 +165,7 @@ func newConfig(availableEnv map[string]string) android.Config {
|
|||||||
// Bazel-enabled mode. Attaches a mutator to queue Bazel requests, adds a
|
// Bazel-enabled mode. Attaches a mutator to queue Bazel requests, adds a
|
||||||
// BeforePrepareBuildActionsHook to invoke Bazel, and then uses Bazel metadata
|
// BeforePrepareBuildActionsHook to invoke Bazel, and then uses Bazel metadata
|
||||||
// for modules that should be handled by Bazel.
|
// for modules that should be handled by Bazel.
|
||||||
func runMixedModeBuild(configuration android.Config, ctx *android.Context, extraNinjaDeps []string) {
|
func runMixedModeBuild(configuration android.Config, ctx *android.Context, extraNinjaDeps []string) string {
|
||||||
ctx.EventHandler.Begin("mixed_build")
|
ctx.EventHandler.Begin("mixed_build")
|
||||||
defer ctx.EventHandler.End("mixed_build")
|
defer ctx.EventHandler.End("mixed_build")
|
||||||
|
|
||||||
@@ -188,6 +188,7 @@ func runMixedModeBuild(configuration android.Config, ctx *android.Context, extra
|
|||||||
ninjaDeps = append(ninjaDeps, globListFiles...)
|
ninjaDeps = append(ninjaDeps, globListFiles...)
|
||||||
|
|
||||||
writeDepFile(cmdlineArgs.OutFile, ctx.EventHandler, ninjaDeps)
|
writeDepFile(cmdlineArgs.OutFile, ctx.EventHandler, ninjaDeps)
|
||||||
|
return cmdlineArgs.OutFile
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the code-generation phase to convert BazelTargetModules to BUILD files.
|
// Run the code-generation phase to convert BazelTargetModules to BUILD files.
|
||||||
@@ -356,53 +357,59 @@ func doChosenActivity(ctx *android.Context, configuration android.Config, extraN
|
|||||||
// Blueprint to BUILD files before everything else.
|
// Blueprint to BUILD files before everything else.
|
||||||
runBp2Build(configuration, extraNinjaDeps, metricsDir)
|
runBp2Build(configuration, extraNinjaDeps, metricsDir)
|
||||||
return bp2buildMarker
|
return bp2buildMarker
|
||||||
} else if configuration.IsMixedBuildsEnabled() {
|
|
||||||
runMixedModeBuild(configuration, ctx, extraNinjaDeps)
|
|
||||||
} else if configuration.BuildMode == android.ApiBp2build {
|
} else if configuration.BuildMode == android.ApiBp2build {
|
||||||
return runApiBp2build(configuration, extraNinjaDeps)
|
return runApiBp2build(configuration, extraNinjaDeps)
|
||||||
} else {
|
} else {
|
||||||
var stopBefore bootstrap.StopBefore
|
if configuration.IsMixedBuildsEnabled() {
|
||||||
if configuration.BuildMode == android.GenerateModuleGraph {
|
return runMixedModeBuild(configuration, ctx, extraNinjaDeps)
|
||||||
stopBefore = bootstrap.StopBeforeWriteNinja
|
|
||||||
} else if configuration.BuildMode == android.GenerateQueryView || configuration.BuildMode == android.GenerateDocFile {
|
|
||||||
stopBefore = bootstrap.StopBeforePrepareBuildActions
|
|
||||||
} else {
|
} else {
|
||||||
stopBefore = bootstrap.DoEverything
|
return runSoongOnlyBuild(configuration, ctx, extraNinjaDeps)
|
||||||
}
|
|
||||||
|
|
||||||
ninjaDeps := bootstrap.RunBlueprint(cmdlineArgs, stopBefore, ctx.Context, configuration)
|
|
||||||
ninjaDeps = append(ninjaDeps, extraNinjaDeps...)
|
|
||||||
|
|
||||||
globListFiles := writeBuildGlobsNinjaFile(ctx, configuration.SoongOutDir(), configuration)
|
|
||||||
ninjaDeps = append(ninjaDeps, globListFiles...)
|
|
||||||
|
|
||||||
// Convert the Soong module graph into Bazel BUILD files.
|
|
||||||
if configuration.BuildMode == android.GenerateQueryView {
|
|
||||||
queryviewMarkerFile := bazelQueryViewDir + ".marker"
|
|
||||||
runQueryView(bazelQueryViewDir, queryviewMarkerFile, configuration, ctx)
|
|
||||||
writeDepFile(queryviewMarkerFile, ctx.EventHandler, ninjaDeps)
|
|
||||||
return queryviewMarkerFile
|
|
||||||
} else if configuration.BuildMode == android.GenerateModuleGraph {
|
|
||||||
writeJsonModuleGraphAndActions(ctx, moduleGraphFile, moduleActionsFile)
|
|
||||||
writeDepFile(moduleGraphFile, ctx.EventHandler, ninjaDeps)
|
|
||||||
return moduleGraphFile
|
|
||||||
} else if configuration.BuildMode == android.GenerateDocFile {
|
|
||||||
// TODO: we could make writeDocs() return the list of documentation files
|
|
||||||
// written and add them to the .d file. Then soong_docs would be re-run
|
|
||||||
// whenever one is deleted.
|
|
||||||
if err := writeDocs(ctx, shared.JoinPath(topDir, docFile)); err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "error building Soong documentation: %s\n", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
writeDepFile(docFile, ctx.EventHandler, ninjaDeps)
|
|
||||||
return docFile
|
|
||||||
} else {
|
|
||||||
// The actual output (build.ninja) was written in the RunBlueprint() call
|
|
||||||
// above
|
|
||||||
writeDepFile(cmdlineArgs.OutFile, ctx.EventHandler, ninjaDeps)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// runSoongOnlyBuild runs the standard Soong build in a number of different modes.
|
||||||
|
func runSoongOnlyBuild(configuration android.Config, ctx *android.Context, extraNinjaDeps []string) string {
|
||||||
|
var stopBefore bootstrap.StopBefore
|
||||||
|
if configuration.BuildMode == android.GenerateModuleGraph {
|
||||||
|
stopBefore = bootstrap.StopBeforeWriteNinja
|
||||||
|
} else if configuration.BuildMode == android.GenerateQueryView || configuration.BuildMode == android.GenerateDocFile {
|
||||||
|
stopBefore = bootstrap.StopBeforePrepareBuildActions
|
||||||
|
} else {
|
||||||
|
stopBefore = bootstrap.DoEverything
|
||||||
|
}
|
||||||
|
|
||||||
|
ninjaDeps := bootstrap.RunBlueprint(cmdlineArgs, stopBefore, ctx.Context, configuration)
|
||||||
|
ninjaDeps = append(ninjaDeps, extraNinjaDeps...)
|
||||||
|
|
||||||
|
globListFiles := writeBuildGlobsNinjaFile(ctx, configuration.SoongOutDir(), configuration)
|
||||||
|
ninjaDeps = append(ninjaDeps, globListFiles...)
|
||||||
|
|
||||||
|
// Convert the Soong module graph into Bazel BUILD files.
|
||||||
|
if configuration.BuildMode == android.GenerateQueryView {
|
||||||
|
queryviewMarkerFile := bazelQueryViewDir + ".marker"
|
||||||
|
runQueryView(bazelQueryViewDir, queryviewMarkerFile, configuration, ctx)
|
||||||
|
writeDepFile(queryviewMarkerFile, ctx.EventHandler, ninjaDeps)
|
||||||
|
return queryviewMarkerFile
|
||||||
|
} else if configuration.BuildMode == android.GenerateModuleGraph {
|
||||||
|
writeJsonModuleGraphAndActions(ctx, moduleGraphFile, moduleActionsFile)
|
||||||
|
writeDepFile(moduleGraphFile, ctx.EventHandler, ninjaDeps)
|
||||||
|
return moduleGraphFile
|
||||||
|
} else if configuration.BuildMode == android.GenerateDocFile {
|
||||||
|
// TODO: we could make writeDocs() return the list of documentation files
|
||||||
|
// written and add them to the .d file. Then soong_docs would be re-run
|
||||||
|
// whenever one is deleted.
|
||||||
|
if err := writeDocs(ctx, shared.JoinPath(topDir, docFile)); err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "error building Soong documentation: %s\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
writeDepFile(docFile, ctx.EventHandler, ninjaDeps)
|
||||||
|
return docFile
|
||||||
|
} else {
|
||||||
|
// The actual output (build.ninja) was written in the RunBlueprint() call
|
||||||
|
// above
|
||||||
|
writeDepFile(cmdlineArgs.OutFile, ctx.EventHandler, ninjaDeps)
|
||||||
|
}
|
||||||
return cmdlineArgs.OutFile
|
return cmdlineArgs.OutFile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user