summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Samuels <richard.l.samuels@gmail.com>2022-06-22 11:31:19 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-07-27 17:08:14 +0000
commit780a878f2238643b99ad2632d7821c4b8434fa12 (patch)
tree8b305c3bcc2765543709406106af39b5be568fff
parente4528b06f85b1431f5526e5acb14aa58cb8bfcf7 (diff)
downloadmongo-780a878f2238643b99ad2632d7821c4b8434fa12.tar.gz
SERVER-67122 Add warning when requesting a module that doesn't exist or when loading legacy ninja module
(cherry picked from commit 7da265df0f82719bc642fc0e28718780ebd7c9b2) (cherry picked from commit 5a407c480493ec4dfd9c18d2c94d6238f0fba36c) (cherry picked from commit b90f5c38ff9101a806ba35384aec59f8e24b9eb5)
-rwxr-xr-xSConstruct26
-rw-r--r--buildscripts/moduleconfig.py16
2 files changed, 35 insertions, 7 deletions
diff --git a/SConstruct b/SConstruct
index 0e784010ae5..5e64f637e37 100755
--- a/SConstruct
+++ b/SConstruct
@@ -2261,13 +2261,25 @@ if get_option("system-boost-lib-search-suffixes") is not None:
# discover modules, and load the (python) module for each module's build.py
mongo_modules = moduleconfig.discover_modules('src/mongo/db/modules', get_option('modules'))
-if get_option('ninja') != 'disabled':
- for module in mongo_modules:
- if hasattr(module, 'NinjaFile'):
- env.FatalError(textwrap.dedent("""\
- ERROR: Ninja tool option '--ninja' should not be used with the ninja module.
- Remove the ninja module directory or use '--modules= ' to select no modules.
- If using enterprise module, explicitly set '--modules=<name-of-enterprise-module>' to exclude the ninja module."""))
+has_ninja_module = False
+for module in mongo_modules:
+ if hasattr(module, 'NinjaFile'):
+ has_ninja_module = True
+ break
+
+if get_option('ninja') != 'disabled' and has_ninja_module:
+ env.FatalError(
+ textwrap.dedent("""\
+ ERROR: Ninja tool option '--ninja' should not be used with the ninja module.
+ Using both options simultaneously may clobber build.ninja files.
+ Remove the ninja module directory or use '--modules= ' to select no modules.
+ If using enterprise module, explicitly set '--modules=<name-of-enterprise-module>' to exclude the ninja module."""
+ ))
+
+if has_ninja_module:
+ print(
+ "WARNING: You are attempting to use the unsupported/legacy ninja module, instead of the integrated ninja generator. You are strongly encouraged to remove the ninja module from your module list and invoke scons with --ninja generate-ninja"
+ )
# --- check system ---
ssl_provider = None
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