diff options
author | Richard Samuels <richard.l.samuels@gmail.com> | 2022-06-22 11:31:19 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-06-22 12:01:12 +0000 |
commit | 7da265df0f82719bc642fc0e28718780ebd7c9b2 (patch) | |
tree | 1c1b244602477b473d147e0155994191ac60baa6 /buildscripts | |
parent | 2c2d85e73d0620d779544ce67218db171c154e8b (diff) | |
download | mongo-7da265df0f82719bc642fc0e28718780ebd7c9b2.tar.gz |
SERVER-67122 Add warning when requesting a module that doesn't exist or when loading legacy ninja module
Diffstat (limited to 'buildscripts')
-rw-r--r-- | buildscripts/moduleconfig.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/buildscripts/moduleconfig.py b/buildscripts/moduleconfig.py index b31a9dbf8db..b4d0bba0490 100644 --- a/buildscripts/moduleconfig.py +++ b/buildscripts/moduleconfig.py @@ -33,16 +33,26 @@ import os def discover_modules(module_root, allowed_modules): + # pylint: disable=too-many-branches """Scan module_root for subdirectories that look like MongoDB modules. Return a list of imported build.py module objects. """ found_modules = [] + found_module_names = [] if allowed_modules is not None: allowed_modules = allowed_modules.split(',') + # When `--modules=` is passed, the split on empty string is represented + # in memory as [''] + if allowed_modules == ['']: + allowed_modules = [] if not os.path.isdir(module_root): + if allowed_modules: + raise RuntimeError( + f"Requested the following modules: {allowed_modules}, but the module root '{module_root}' could not be found. Check the module root, or remove the module from the scons invocation." + ) return found_modules for name in os.listdir(module_root): @@ -66,11 +76,17 @@ def discover_modules(module_root, allowed_modules): if getattr(module, "name", None) is None: module.name = name found_modules.append(module) + found_module_names.append(name) finally: fp.close() except (FileNotFoundError, IOError): pass + if allowed_modules is not None: + missing_modules = set(allowed_modules) - set(found_module_names) + if missing_modules: + raise RuntimeError(f"Failed to locate all modules. Could not find: {missing_modules}") + return found_modules |