From b713ddfcc12f39d50ab3a397e128c9d89be3a0e6 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Sat, 5 Nov 2022 16:14:30 +0000 Subject: [PATCH] Build mode function should return output file Each build mode has to provide an output file, which also has a corresponding dependency 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 --- cmd/soong_build/main.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go index 99f0e3beb..5a96314ca 100644 --- a/cmd/soong_build/main.go +++ b/cmd/soong_build/main.go @@ -348,13 +348,11 @@ func writeDepFile(outputFile string, eventHandler *metrics.EventHandler, ninjaDe // output file of the specific activity. func doChosenActivity(ctx *android.Context, configuration android.Config, extraNinjaDeps []string, metricsDir string) string { if configuration.BuildMode == android.SymlinkForest { - runSymlinkForestCreation(configuration, ctx, extraNinjaDeps, metricsDir) - return symlinkForestMarker + return runSymlinkForestCreation(configuration, ctx, extraNinjaDeps, metricsDir) } else if configuration.BuildMode == android.Bp2build { // Run the alternate pipeline of bp2build mutators and singleton to convert // Blueprint to BUILD files before everything else. - runBp2Build(configuration, ctx, extraNinjaDeps, metricsDir) - return bp2buildMarker + return runBp2Build(configuration, ctx, extraNinjaDeps, metricsDir) } else if configuration.BuildMode == android.ApiBp2build { outputFile := runApiBp2build(configuration, ctx, extraNinjaDeps) 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 // above writeDepFile(cmdlineArgs.OutFile, ctx.EventHandler, ninjaDeps) + return cmdlineArgs.OutFile } - return cmdlineArgs.OutFile } // 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 // symlink tree creation binary. Then the latter would not need to depend on // 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 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 } writeBp2BuildMetrics(codegenMetrics, ctx.EventHandler, metricsDir) + + return symlinkForestMarker } // Run Soong in the bp2build mode. This creates a standalone context that registers // an alternate pipeline of mutators and singletons specifically for generating // 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 ctx.EventHandler.Do("bp2build", func() { @@ -722,6 +722,7 @@ func runBp2Build(configuration android.Config, ctx *android.Context, extraNinjaD codegenMetrics.Print() } writeBp2BuildMetrics(codegenMetrics, ctx.EventHandler, metricsDir) + return bp2buildMarker } // Write Bp2Build metrics into $LOG_DIR