diff options
author | Daniel Moody <daniel.moody@mongodb.com> | 2020-08-24 15:00:18 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-25 22:29:28 +0000 |
commit | 8f42fecbeae2e6841b94b1448a6d3cbdc637ad8a (patch) | |
tree | d634ab2cfbb28825edbe8ab014f7504f5f88fbaa /site_scons | |
parent | 2a2b8192ba25bb21ba35ca271e66cc534ee35aca (diff) | |
download | mongo-8f42fecbeae2e6841b94b1448a6d3cbdc637ad8a.tar.gz |
SERVER-49760 Added libdep lint rule to enforce no public libdeps.
Diffstat (limited to 'site_scons')
-rw-r--r-- | site_scons/libdeps.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/site_scons/libdeps.py b/site_scons/libdeps.py index 888b2fd2882..1158bcda557 100644 --- a/site_scons/libdeps.py +++ b/site_scons/libdeps.py @@ -230,6 +230,30 @@ class LibdepLinter(object): )) @linter_rule + def linter_rule_no_public_deps(self, libdep): + """ + LIBDEP RULE: + Nodes explicitly marked as not allowed to have public dependencies, should not + have public dependencies, unless the dependency is explicitly marked as allowed. + """ + if not self._check_for_lint_tags('lint-no-public-deps', inclusive_tag=True): + return + + if libdep.dependency_type != dependency.Private: + # Check if the libdep exempts itself from this rule. + if self._check_for_lint_tags('lint-public-dep-allowed', 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 public dependency '{lib}' + while being marked as not allowed to have public dependencies + and '{lib}' does not exempt itself.""" + )) + + @linter_rule def linter_rule_no_dups(self, libdep): """ LIBDEP RULE: |