Avoid writing soong_build_metrics.pb multiple times
Previously, running `m nothing` would write the soong_build_metrics.pb file 3 times: 1. For bp2build - it contains a single `soong_build` event as the rest is written to the `bp2build_metrics.pb` file. 2. For Bazel symlink forrest - it too contains a single `soong_build` event as the rest is appended to the `bp2build_metrics.pb` file. 3. For soong_build proper (including mixed builds) - it contains useful information. This change avoids that by pushing the code to write the soong_build_metrics.pb file from the top level where it applies to all build modes into the build mode specific function that needs it. Bug: 257590265 Test: m nothing # Run with some logging to make sure the file is only created once. Change-Id: Iee239fb87edf443fed65156fa14b8a30c89a2328 Change-Id: I09724f6143352de6b7d6fb29eaf3fbed5a1abd21
This commit is contained in:
@@ -358,18 +358,29 @@ func doChosenActivity(ctx *android.Context, configuration android.Config, extraN
|
||||
runBp2Build(configuration, extraNinjaDeps, metricsDir)
|
||||
return bp2buildMarker
|
||||
} else if configuration.BuildMode == android.ApiBp2build {
|
||||
return runApiBp2build(configuration, extraNinjaDeps)
|
||||
outputFile := runApiBp2build(configuration, extraNinjaDeps)
|
||||
writeMetrics(configuration, ctx.EventHandler, metricsDir)
|
||||
return outputFile
|
||||
} else {
|
||||
|
||||
var outputFile string
|
||||
if configuration.IsMixedBuildsEnabled() {
|
||||
return runMixedModeBuild(configuration, ctx, extraNinjaDeps)
|
||||
outputFile = runMixedModeBuild(configuration, ctx, extraNinjaDeps)
|
||||
} else {
|
||||
return runSoongOnlyBuild(configuration, ctx, extraNinjaDeps)
|
||||
outputFile = runSoongOnlyBuild(configuration, ctx, extraNinjaDeps)
|
||||
}
|
||||
|
||||
writeMetrics(configuration, ctx.EventHandler, metricsDir)
|
||||
|
||||
return outputFile
|
||||
}
|
||||
}
|
||||
|
||||
// runSoongOnlyBuild runs the standard Soong build in a number of different modes.
|
||||
func runSoongOnlyBuild(configuration android.Config, ctx *android.Context, extraNinjaDeps []string) string {
|
||||
ctx.EventHandler.Begin("soong_build")
|
||||
defer ctx.EventHandler.End("soong_build")
|
||||
|
||||
var stopBefore bootstrap.StopBefore
|
||||
if configuration.BuildMode == android.GenerateModuleGraph {
|
||||
stopBefore = bootstrap.StopBeforeWriteNinja
|
||||
@@ -470,13 +481,9 @@ func main() {
|
||||
logDir := availableEnv["LOG_DIR"]
|
||||
|
||||
ctx := newContext(configuration)
|
||||
ctx.EventHandler.Begin("soong_build")
|
||||
|
||||
finalOutputFile := doChosenActivity(ctx, configuration, extraNinjaDeps, logDir)
|
||||
|
||||
ctx.EventHandler.End("soong_build")
|
||||
writeMetrics(configuration, ctx.EventHandler, logDir)
|
||||
|
||||
writeUsedEnvironmentFile(configuration, finalOutputFile)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user