Add --bazel-mode and --bazel-mode-dev

This allows "bazel mixed builds prod mode", in additional to reworking
the mechanism in which mixed builds dev mode is enabled.

As a followup, CI scripts will be migrated to use the new flags, as
USE_BAZEL_ANALYSIS=1 is deprecated.

Test: Manually ran --bazel-mode with an allowlist verifying that the
module alone was enabled
Test: Manually verified --bazel-mode and --bazel-mode-dev cause a build
failure

Change-Id: If0d34360e60452f428b05828f4ec7596b7cb619a
This commit is contained in:
Chris Parsons
2022-08-18 22:04:11 -04:00
parent 5e7c4756b5
commit ef615e5841
9 changed files with 123 additions and 64 deletions

View File

@@ -254,6 +254,12 @@ func bootstrapBlueprint(ctx Context, config Config) {
if config.EmptyNinjaFile() {
mainSoongBuildExtraArgs = append(mainSoongBuildExtraArgs, "--empty-ninja-file")
}
if config.bazelProdMode {
mainSoongBuildExtraArgs = append(mainSoongBuildExtraArgs, "--bazel-mode")
}
if config.bazelDevMode {
mainSoongBuildExtraArgs = append(mainSoongBuildExtraArgs, "--bazel-mode-dev")
}
mainSoongBuildInvocation := primaryBuilderInvocation(
config,
@@ -263,7 +269,7 @@ func bootstrapBlueprint(ctx Context, config Config) {
fmt.Sprintf("analyzing Android.bp files and generating ninja file at %s", config.SoongNinjaFile()),
)
if config.bazelBuildMode() == mixedBuild {
if config.BazelBuildEnabled() {
// Mixed builds call Bazel from soong_build and they therefore need the
// Bazel workspace to be available. Make that so by adding a dependency on
// the bp2build marker file to the action that invokes soong_build .
@@ -373,9 +379,6 @@ func runSoong(ctx Context, config Config) {
// unused variables were changed?
envFile := filepath.Join(config.SoongOutDir(), availableEnvFile)
buildMode := config.bazelBuildMode()
integratedBp2Build := buildMode == mixedBuild
// This is done unconditionally, but does not take a measurable amount of time
bootstrapBlueprint(ctx, config)
@@ -405,7 +408,7 @@ func runSoong(ctx Context, config Config) {
checkEnvironmentFile(soongBuildEnv, config.UsedEnvFile(soongBuildTag))
if integratedBp2Build || config.Bp2Build() {
if config.BazelBuildEnabled() || config.Bp2Build() {
checkEnvironmentFile(soongBuildEnv, config.UsedEnvFile(bp2buildTag))
}