diff options
| -rw-r--r-- | kconfiglib.py | 30 | ||||
| -rw-r--r-- | tests/Kreferenced | 20 | ||||
| -rw-r--r-- | testsuite.py | 5 |
3 files changed, 53 insertions, 2 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index d62c7a8..2741e10 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -3334,6 +3334,20 @@ class Symbol(object): self.user_value = None self._rec_invalidate_if_has_prompt() + def referenced(self): + """ + Returns a set() of all symbols and choices referenced in the properties + and property conditions of the symbol. + + Also includes dependencies inherited from surrounding menus and if's. + Choices appear in the dependencies of choice symbols. + """ + res = set() + for node in self.nodes: + res |= node.referenced() + + return res + def __repr__(self): """ Returns a string with information about the symbol (including its name, @@ -3911,6 +3925,20 @@ class Choice(object): self.user_value = self.user_selection = None self._rec_invalidate() + def referenced(self): + """ + Returns a set() of all symbols and choices referenced in the properties + and property conditions of the choice. + + Also includes dependencies inherited from surrounding menus and if's. + Choices appear in the dependencies of choice symbols. + """ + res = set() + for node in self.nodes: + res |= node.referenced() + + return res + def __repr__(self): """ Returns a string with information about the choice when it is evaluated @@ -4201,7 +4229,7 @@ class MenuNode(object): def referenced(self): """ Returns a set() of all symbols and choices referenced in the properties - and property conditions of this menu node. + and property conditions of the menu node. Also includes dependencies inherited from surrounding menus and if's. Choices appear in the dependencies of choice symbols. diff --git a/tests/Kreferenced b/tests/Kreferenced index 8dda5a2..9da94c8 100644 --- a/tests/Kreferenced +++ b/tests/Kreferenced @@ -41,3 +41,23 @@ endchoice comment "comment" depends on A || B + + +config MULTI_DEF_SYM + def_bool A && B + +config MULTI_DEF_SYM + depends on C + + +choice MULTI_DEF_CHOICE + bool "choice" + depends on A && B + +endchoice + +choice MULTI_DEF_CHOICE + bool "choice" + depends on C + +endchoice diff --git a/testsuite.py b/testsuite.py index bbb4c37..8f93c81 100644 --- a/testsuite.py +++ b/testsuite.py @@ -1009,7 +1009,7 @@ g ) - print("Testing MenuNode.referenced()") + print("Testing MenuNode/Symbol/Choice.referenced()") c = Kconfig("Kconfiglib/tests/Kreferenced", warn=False) @@ -1035,6 +1035,9 @@ g verify_deps(c.comments[0], "A", "B") + verify_deps(c.syms["MULTI_DEF_SYM"], "A", "B", "C", "y") + verify_deps(c.named_choices["MULTI_DEF_CHOICE"], "A", "B", "C") + print("Testing split_expr()") |
