From 1de78f3174e5a4bd3bdc27337e2b25b673f67222 Mon Sep 17 00:00:00 2001 From: MarkDacek Date: Tue, 2 May 2023 21:00:48 +0000 Subject: [PATCH] Fix instantiation of config.bazelForceEnabledModules Currently, uninstantiated, the field will be set to [""] instead of an empty slice. Test: m nothing --ensure-allowlist-integrity Test: m nothing --ensure-allowlist-integrity --bazel-force-enabled-modules=com.google.android.neuralnetworks (this fails, as expected) Change-Id: Ib4cd26f0cb0d40714b8c3f263ee2d22093ee15ef --- android/config.go | 9 ++++++++- cmd/soong_build/main.go | 4 ---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/android/config.go b/android/config.go index 526537406..9e94e0517 100644 --- a/android/config.go +++ b/android/config.go @@ -606,7 +606,7 @@ func NewConfig(cmdArgs CmdArgs, availableEnv map[string]string) (Config, error) setBazelMode(cmdArgs.BazelMode, "--bazel-mode", BazelProdMode) setBazelMode(cmdArgs.BazelModeStaging, "--bazel-mode-staging", BazelStagingMode) - for _, module := range strings.Split(cmdArgs.BazelForceEnabledModules, ",") { + for _, module := range getForceEnabledModulesFromFlag(cmdArgs.BazelForceEnabledModules) { config.bazelForceEnabledModules[module] = struct{}{} } config.BazelContext, err = NewBazelContext(config) @@ -615,6 +615,13 @@ func NewConfig(cmdArgs CmdArgs, availableEnv map[string]string) (Config, error) return Config{config}, err } +func getForceEnabledModulesFromFlag(forceEnabledFlag string) []string { + if forceEnabledFlag == "" { + return []string{} + } + return strings.Split(forceEnabledFlag, ",") +} + // mockFileSystem replaces all reads with accesses to the provided map of // filenames to contents stored as a byte slice. func (c *config) mockFileSystem(bp string, fs map[string][]byte) { diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go index f347b8f56..c22fd80b9 100644 --- a/cmd/soong_build/main.go +++ b/cmd/soong_build/main.go @@ -307,10 +307,6 @@ func checkForAllowlistIntegrityError(configuration android.Config, isStagingMode // 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 {