Build mode function should return output file
Each build mode has to provide an output file, which also has a corresponding dependency file (<output file>.d). Previously, some of the build mode functions returned that file, others just returned and relied on the doChosenActivity() method to return the file. That was confusing as the same file name was referenced from two separate places. This change makes all the build mode functions return their output file explicitly and the doChosenActivity()just returns what it receives. It also moves the writeDepsFile call to adjacent to the return. Bug: 257650737 Test: m nothing Change-Id: I35f96ab404d9ffb1da747a3ecb8fc4e1feb9c026
This commit is contained in:
@@ -348,13 +348,11 @@ func writeDepFile(outputFile string, eventHandler *metrics.EventHandler, ninjaDe
|
|||||||
// output file of the specific activity.
|
// output file of the specific activity.
|
||||||
func doChosenActivity(ctx *android.Context, configuration android.Config, extraNinjaDeps []string, metricsDir string) string {
|
func doChosenActivity(ctx *android.Context, configuration android.Config, extraNinjaDeps []string, metricsDir string) string {
|
||||||
if configuration.BuildMode == android.SymlinkForest {
|
if configuration.BuildMode == android.SymlinkForest {
|
||||||
runSymlinkForestCreation(configuration, ctx, extraNinjaDeps, metricsDir)
|
return runSymlinkForestCreation(configuration, ctx, extraNinjaDeps, metricsDir)
|
||||||
return symlinkForestMarker
|
|
||||||
} else if configuration.BuildMode == android.Bp2build {
|
} else if configuration.BuildMode == android.Bp2build {
|
||||||
// Run the alternate pipeline of bp2build mutators and singleton to convert
|
// Run the alternate pipeline of bp2build mutators and singleton to convert
|
||||||
// Blueprint to BUILD files before everything else.
|
// Blueprint to BUILD files before everything else.
|
||||||
runBp2Build(configuration, ctx, extraNinjaDeps, metricsDir)
|
return runBp2Build(configuration, ctx, extraNinjaDeps, metricsDir)
|
||||||
return bp2buildMarker
|
|
||||||
} else if configuration.BuildMode == android.ApiBp2build {
|
} else if configuration.BuildMode == android.ApiBp2build {
|
||||||
outputFile := runApiBp2build(configuration, ctx, extraNinjaDeps)
|
outputFile := runApiBp2build(configuration, ctx, extraNinjaDeps)
|
||||||
writeMetrics(configuration, ctx.EventHandler, metricsDir)
|
writeMetrics(configuration, ctx.EventHandler, metricsDir)
|
||||||
@@ -419,8 +417,8 @@ func runSoongOnlyBuild(configuration android.Config, ctx *android.Context, extra
|
|||||||
// The actual output (build.ninja) was written in the RunBlueprint() call
|
// The actual output (build.ninja) was written in the RunBlueprint() call
|
||||||
// above
|
// above
|
||||||
writeDepFile(cmdlineArgs.OutFile, ctx.EventHandler, ninjaDeps)
|
writeDepFile(cmdlineArgs.OutFile, ctx.EventHandler, ninjaDeps)
|
||||||
|
return cmdlineArgs.OutFile
|
||||||
}
|
}
|
||||||
return cmdlineArgs.OutFile
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// soong_ui dumps the available environment variables to
|
// soong_ui dumps the available environment variables to
|
||||||
@@ -627,7 +625,7 @@ func bazelArtifacts() []string {
|
|||||||
// Ideally, bp2build would write a file that contains instructions to the
|
// Ideally, bp2build would write a file that contains instructions to the
|
||||||
// symlink tree creation binary. Then the latter would not need to depend on
|
// symlink tree creation binary. Then the latter would not need to depend on
|
||||||
// the very heavy-weight machinery of soong_build .
|
// the very heavy-weight machinery of soong_build .
|
||||||
func runSymlinkForestCreation(configuration android.Config, ctx *android.Context, extraNinjaDeps []string, metricsDir string) {
|
func runSymlinkForestCreation(configuration android.Config, ctx *android.Context, extraNinjaDeps []string, metricsDir string) string {
|
||||||
var ninjaDeps []string
|
var ninjaDeps []string
|
||||||
ninjaDeps = append(ninjaDeps, extraNinjaDeps...)
|
ninjaDeps = append(ninjaDeps, extraNinjaDeps...)
|
||||||
|
|
||||||
@@ -671,12 +669,14 @@ func runSymlinkForestCreation(configuration android.Config, ctx *android.Context
|
|||||||
//invocation of codegen. We should simply use a separate .pb file
|
//invocation of codegen. We should simply use a separate .pb file
|
||||||
}
|
}
|
||||||
writeBp2BuildMetrics(codegenMetrics, ctx.EventHandler, metricsDir)
|
writeBp2BuildMetrics(codegenMetrics, ctx.EventHandler, metricsDir)
|
||||||
|
|
||||||
|
return symlinkForestMarker
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run Soong in the bp2build mode. This creates a standalone context that registers
|
// Run Soong in the bp2build mode. This creates a standalone context that registers
|
||||||
// an alternate pipeline of mutators and singletons specifically for generating
|
// an alternate pipeline of mutators and singletons specifically for generating
|
||||||
// Bazel BUILD files instead of Ninja files.
|
// Bazel BUILD files instead of Ninja files.
|
||||||
func runBp2Build(configuration android.Config, ctx *android.Context, extraNinjaDeps []string, metricsDir string) {
|
func runBp2Build(configuration android.Config, ctx *android.Context, extraNinjaDeps []string, metricsDir string) string {
|
||||||
var codegenMetrics *bp2build.CodegenMetrics
|
var codegenMetrics *bp2build.CodegenMetrics
|
||||||
ctx.EventHandler.Do("bp2build", func() {
|
ctx.EventHandler.Do("bp2build", func() {
|
||||||
|
|
||||||
@@ -722,6 +722,7 @@ func runBp2Build(configuration android.Config, ctx *android.Context, extraNinjaD
|
|||||||
codegenMetrics.Print()
|
codegenMetrics.Print()
|
||||||
}
|
}
|
||||||
writeBp2BuildMetrics(codegenMetrics, ctx.EventHandler, metricsDir)
|
writeBp2BuildMetrics(codegenMetrics, ctx.EventHandler, metricsDir)
|
||||||
|
return bp2buildMarker
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write Bp2Build metrics into $LOG_DIR
|
// Write Bp2Build metrics into $LOG_DIR
|
||||||
|
Reference in New Issue
Block a user