diff options
author | 2021-01-28 08:22:12 -0500 | |
---|---|---|
committer | 2021-01-29 22:33:25 -0500 | |
commit | eb76c4319d5aa9981cef24f8a645d89729c5aa92 (patch) | |
tree | 43c7418fe5ec00c348f6c0806092cbce5644c799 /ui | |
parent | 3b171f40137beb828a7f25f0bb9e55c445037c86 (diff) |
bp2build: fix running from clean checkout.
bp2build is a Soong mode that returns as soon as the BUILD files are generated. This causes it not generate the build.ninja file, which the Ninja process executing soong_build itself expects to produce as an output. If there isn't an existing build.ninja file generated from a previous build, GENERATE_BAZEL_FILES=true m nothing will fail.
This CL generates the expected files as a workaround, and also makes GENERATE_BAZEL_FILES=true skip the Kati/Ninja steps in soong_ui since they aren't needed.
Test: rm -rf out/ && GENERATE_BAZEL_FILES=true m nothing && m libc
Fixes: 178683777
Change-Id: I2515ef7961682d2be5f096ed24831cc185165a67
Diffstat (limited to 'ui')
-rw-r--r-- | ui/build/build.go | 5 | ||||
-rw-r--r-- | ui/build/soong.go | 14 |
2 files changed, 16 insertions, 3 deletions
diff --git a/ui/build/build.go b/ui/build/build.go index 926da3137..215a6c8ce 100644 --- a/ui/build/build.go +++ b/ui/build/build.go @@ -252,6 +252,11 @@ func Build(ctx Context, config Config, what int) { if what&BuildSoong != 0 { // Run Soong runSoong(ctx, config) + + if config.Environment().IsEnvTrue("GENERATE_BAZEL_FILES") { + // Return early, if we're using Soong as the bp2build converter. + return + } } if what&BuildKati != 0 { diff --git a/ui/build/soong.go b/ui/build/soong.go index 6a9367259..899ab5da5 100644 --- a/ui/build/soong.go +++ b/ui/build/soong.go @@ -169,8 +169,11 @@ func runSoong(ctx Context, config Config) { // This build generates <builddir>/build.ninja, which is used later by build/soong/ui/build/build.go#Build(). ninja("bootstrap", ".bootstrap/build.ninja") - soongBuildMetrics := loadSoongBuildMetrics(ctx, config) - logSoongBuildMetrics(ctx, soongBuildMetrics) + var soongBuildMetrics *soong_metrics_proto.SoongBuildMetrics + if shouldCollectBuildSoongMetrics(config) { + soongBuildMetrics := loadSoongBuildMetrics(ctx, config) + logSoongBuildMetrics(ctx, soongBuildMetrics) + } distGzipFile(ctx, config, config.SoongNinjaFile(), "soong") @@ -179,11 +182,16 @@ func runSoong(ctx Context, config Config) { distGzipFile(ctx, config, config.SoongMakeVarsMk(), "soong") } - if ctx.Metrics != nil { + if shouldCollectBuildSoongMetrics(config) && ctx.Metrics != nil { ctx.Metrics.SetSoongBuildMetrics(soongBuildMetrics) } } +func shouldCollectBuildSoongMetrics(config Config) bool { + // Do not collect metrics protobuf if the soong_build binary ran as the bp2build converter. + return config.Environment().IsFalse("GENERATE_BAZEL_FILES") +} + func loadSoongBuildMetrics(ctx Context, config Config) *soong_metrics_proto.SoongBuildMetrics { soongBuildMetricsFile := filepath.Join(config.OutDir(), "soong", "soong_build_metrics.pb") buf, err := ioutil.ReadFile(soongBuildMetricsFile) |