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
diff --git a/android/bazel_handler.go b/android/bazel_handler.go
index d87f988..93b6779 100644
--- a/android/bazel_handler.go
+++ b/android/bazel_handler.go
@@ -343,7 +343,30 @@
}
func NewBazelContext(c *config) (BazelContext, error) {
- if !c.IsMixedBuildsEnabled() {
+ var modulesDefaultToBazel bool
+ disabledModules := map[string]bool{}
+ enabledModules := map[string]bool{}
+
+ switch c.BuildMode {
+ case BazelProdMode:
+ modulesDefaultToBazel = false
+
+ for _, enabledProdModule := range allowlists.ProdMixedBuildsEnabledList {
+ enabledModules[enabledProdModule] = true
+ }
+ case BazelDevMode:
+ modulesDefaultToBazel = true
+
+ // Don't use partially-converted cc_library targets in mixed builds,
+ // since mixed builds would generally rely on both static and shared
+ // variants of a cc_library.
+ for staticOnlyModule, _ := range GetBp2BuildAllowList().ccLibraryStaticOnly {
+ disabledModules[staticOnlyModule] = true
+ }
+ for _, disabledDevModule := range allowlists.MixedBuildsDisabledList {
+ disabledModules[disabledDevModule] = true
+ }
+ default:
return noopBazelContext{}, nil
}
@@ -352,24 +375,12 @@
return nil, err
}
- // TODO(cparsons): Use a different allowlist depending on prod vs. dev
- // bazel mode.
- disabledModules := map[string]bool{}
- // Don't use partially-converted cc_library targets in mixed builds,
- // since mixed builds would generally rely on both static and shared
- // variants of a cc_library.
- for staticOnlyModule, _ := range GetBp2BuildAllowList().ccLibraryStaticOnly {
- disabledModules[staticOnlyModule] = true
- }
- for _, disabledDevModule := range allowlists.MixedBuildsDisabledList {
- disabledModules[disabledDevModule] = true
- }
-
return &bazelContext{
bazelRunner: &builtinBazelRunner{},
paths: p,
requests: make(map[cqueryKey]bool),
- modulesDefaultToBazel: true,
+ modulesDefaultToBazel: modulesDefaultToBazel,
+ bazelEnabledModules: enabledModules,
bazelDisabledModules: disabledModules,
}, nil
}