summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mark Dacek <dacek@google.com> 2023-05-03 03:34:48 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2023-05-03 03:34:48 +0000
commit833d7ee6e3eebb18e4b43c8c0e90c2a201e5a0f7 (patch)
treed953cdb09fc25bddf03b22b8cb8d1d4303fbf0ff
parentad3f14edf3faa6b6a1a18478e189b11e51e64e6b (diff)
parent6f6b962bd09588be63957c8f6910e1a63a490a51 (diff)
Merge "Modify --ensure-allowlist-integrity call to avoid spurious errors."
-rw-r--r--android/config.go4
-rw-r--r--cmd/soong_build/main.go37
2 files changed, 35 insertions, 6 deletions
diff --git a/android/config.go b/android/config.go
index 0b54ed90c..526537406 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1929,6 +1929,10 @@ func (c *config) GetMixedBuildsEnabledModules() map[string]struct{} {
return c.mixedBuildEnabledModules
}
+func (c *config) GetMixedBuildsDisabledModules() map[string]struct{} {
+ return c.mixedBuildDisabledModules
+}
+
func (c *config) LogMixedBuild(ctx BaseModuleContext, useBazel bool) {
moduleName := ctx.Module().Name()
c.mixedBuildsLock.Lock()
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index 53e0e55c4..f347b8f56 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -289,9 +289,9 @@ func writeMetrics(configuration android.Config, eventHandler *metrics.EventHandl
}
// Errors out if any modules expected to be mixed_built were not, unless
-// there is a platform incompatibility.
+// the modules did not exist.
func checkForAllowlistIntegrityError(configuration android.Config, isStagingMode bool) error {
- modules := findModulesNotMixedBuiltForAnyVariant(configuration, isStagingMode)
+ modules := findMisconfiguredModules(configuration, isStagingMode)
if len(modules) == 0 {
return nil
}
@@ -299,29 +299,54 @@ func checkForAllowlistIntegrityError(configuration android.Config, isStagingMode
return fmt.Errorf("Error: expected the following modules to be mixed_built: %s", modules)
}
+// Returns true if the given module has all of the following true:
+// 1. Is allowlisted to be built with Bazel.
+// 2. Has a variant which is *not* built with Bazel.
+// 3. Has no variant which is built with Bazel.
+//
+// This indicates the allowlisting of this variant had no effect.
+// TODO(b/280457637): Return true for nonexistent modules.
+func isAllowlistMisconfiguredForModule(module string, mixedBuildsEnabled map[string]struct{}, mixedBuildsDisabled map[string]struct{}) bool {
+ //TODO(dacek): Why does this occur in the allowlists?
+ if module == "" {
+ return false
+ }
+ _, enabled := mixedBuildsEnabled[module]
+
+ if enabled {
+ return false
+ }
+
+ _, disabled := mixedBuildsDisabled[module]
+ return disabled
+
+}
+
// Returns the list of modules that should have been mixed_built (per the
// allowlists and cmdline flags) but were not.
-func findModulesNotMixedBuiltForAnyVariant(configuration android.Config, isStagingMode bool) []string {
+// Note: nonexistent modules are excluded from the list. See b/280457637
+func findMisconfiguredModules(configuration android.Config, isStagingMode bool) []string {
retval := []string{}
forceEnabledModules := configuration.BazelModulesForceEnabledByFlag()
mixedBuildsEnabled := configuration.GetMixedBuildsEnabledModules()
+ mixedBuildsDisabled := configuration.GetMixedBuildsDisabledModules()
for _, module := range allowlists.ProdMixedBuildsEnabledList {
- if _, ok := mixedBuildsEnabled[module]; !ok && module != "" {
+ if isAllowlistMisconfiguredForModule(module, mixedBuildsEnabled, mixedBuildsDisabled) {
retval = append(retval, module)
}
}
if isStagingMode {
for _, module := range allowlists.StagingMixedBuildsEnabledList {
- if _, ok := mixedBuildsEnabled[module]; !ok && module != "" {
+ if isAllowlistMisconfiguredForModule(module, mixedBuildsEnabled, mixedBuildsDisabled) {
retval = append(retval, module)
}
}
}
for module, _ := range forceEnabledModules {
- if _, ok := mixedBuildsEnabled[module]; !ok && module != "" {
+ if isAllowlistMisconfiguredForModule(module, mixedBuildsEnabled, mixedBuildsDisabled) {
retval = append(retval, module)
}
}