Skip to content
This repository was archived by the owner on Apr 6, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions scripts/check_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ def run(self):

self.check_top_menu_not_too_long(kconf)
self.check_no_pointless_menuconfigs(kconf)
self.check_no_duplicated_deps(kconf)
self.check_no_undef_within_kconfig(kconf)
self.check_no_undef_outside_kconfig(kconf)

Expand Down Expand Up @@ -361,6 +362,35 @@ def check_no_pointless_menuconfigs(self, kconf):
""" + "\n".join(f"{node.item.name:35} {node.filename}:{node.linenr}"
for node in bad_mconfs))

def check_no_duplicated_deps(self, kconf):
# Checks that there are no duplicated direct dependencies, e.g. a
# 'depends on FOO' on a symbol defined within an 'if FOO'. Duplicated
# dependencies make changes harder to get right, and make the generated
# Kconfig documentation uglier.

# 'kconfiglib' is global
# pylint: disable=undefined-variable

for node in kconf.node_iter():
# Use the string representation of dependencies so that e.g. a
# duplicated !FOO will be caught despite being a different
# (NOT, <FOO>) tuple.
deps = map(kconfiglib.expr_str,
kconfiglib.split_expr(node.dep, kconfiglib.AND))

for dep, count in collections.Counter(deps).items():
if count > 1:
self.add_failure(f"""\
Duplicated {dep} dependency on symbol/choice/menu/comment at
{node.filename}:{node.linenr}:

{node}

Jump to the item in the menuconfig/guiconfig interface (with '/') and check the
'included via ...' path to figure out where the redundant dependency is coming
from. You might have an 'if FOO' within an 'if FOO', or a 'depends on FOO'
within an 'if FOO'.""")

def check_no_undef_within_kconfig(self, kconf):
"""
Checks that there are no references to undefined Kconfig symbols within
Expand Down