diff options
author | Daniel Moody <daniel.moody@mongodb.com> | 2020-08-17 22:30:34 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-21 20:17:47 +0000 |
commit | cc68e42e8df1c6744311852099b1a87b04c568bd (patch) | |
tree | 8f9ab293685785ee16cc1ac8844072d01af56b45 /site_scons/libdeps.py | |
parent | 8cd9ddcadf24703cb87abc4f3e35d42a69d31191 (diff) | |
download | mongo-cc68e42e8df1c6744311852099b1a87b04c568bd.tar.gz |
SERVER-49761 Added libdeps rule for leaf node no dependencies
Diffstat (limited to 'site_scons/libdeps.py')
-rw-r--r-- | site_scons/libdeps.py | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/site_scons/libdeps.py b/site_scons/libdeps.py index 3d297dff1c0..888b2fd2882 100644 --- a/site_scons/libdeps.py +++ b/site_scons/libdeps.py @@ -179,15 +179,19 @@ class LibdepLinter(object): else: raise LibdepLinterError(message) - def _check_for_lint_tags(self, lint_tag, env=None): + def _check_for_lint_tags(self, lint_tag, env=None, inclusive_tag=False): """ Used to get the lint tag from the environment, and if printing instead of raising exceptions, will ignore the tags. """ - # ignore LIBDEP_TAGS if printing was selected - if self.__class__.print_linter_errors: + # If print mode is on, we want to make sure to bypass checking + # exclusive tags so we can make sure the exceptions are not excluded + # and are printed. If it's an inclusive tag, we want to ignore this + # early return completely, because we want to make sure the node + # gets included for checking, and the exception gets printed. + if not inclusive_tag and self.__class__.print_linter_errors: return False target_env = env if env else self.env @@ -203,6 +207,29 @@ class LibdepLinter(object): return deps_dependents @linter_rule + def linter_rule_leaf_node_no_deps(self, libdep): + """ + LIBDEP RULE: + Nodes marked explicitly as a leaf node should not have any dependencies, + unless those dependencies are explicitly marked as allowed as leaf node + dependencies. + """ + if not self._check_for_lint_tags('lint-leaf-node-no-deps', inclusive_tag=True): + return + + # Ignore dependencies that explicitly exempt themselves. + if self._check_for_lint_tags('lint-leaf-node-allowed-dep', libdep.target_node.env): + return + + target_type = self.target[0].builder.get_name(self.env) + lib = os.path.basename(str(libdep)) + self._raise_libdep_lint_exception( + textwrap.dedent(f"""\ + {target_type} '{self.target[0]}' has dependency '{lib}' and is marked explicitly as a leaf node, + and '{lib}' does not exempt itself as an exception to the rule.""" + )) + + @linter_rule def linter_rule_no_dups(self, libdep): """ LIBDEP RULE: |