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

@@ -110,6 +110,24 @@ const (
RunAllWithBazel = RunProductConfig | RunSoong | RunKati | RunKatiNinja | RunBazel
)
// checkBazelMode fails the build if there are conflicting arguments for which bazel
// build mode to use.
func checkBazelMode(ctx Context, config Config) {
// TODO(cparsons): Remove USE_BAZEL_ANALYSIS handling.
if config.Environment().IsEnvTrue("USE_BAZEL_ANALYSIS") {
if config.bazelProdMode || config.bazelDevMode {
ctx.Fatalf("USE_BAZEL_ANALYSIS is deprecated.\n" +
"Unset USE_BAZEL_ANALYSIS when using --bazel-mode or --bazel-mode-dev.")
} else {
config.bazelDevMode = true
}
}
if config.bazelProdMode && config.bazelDevMode {
ctx.Fatalf("Conflicting bazel mode.\n" +
"Do not specify both --bazel-mode and --bazel-mode-dev")
}
}
// checkProblematicFiles fails the build if existing Android.mk or CleanSpec.mk files are found at the root of the tree.
func checkProblematicFiles(ctx Context) {
files := []string{"Android.mk", "CleanSpec.mk"}
@@ -221,6 +239,8 @@ func Build(ctx Context, config Config) {
defer waitForDist(ctx)
checkBazelMode(ctx, config)
// checkProblematicFiles aborts the build if Android.mk or CleanSpec.mk are found at the root of the tree.
checkProblematicFiles(ctx)