From 509e374dfcadbe04ba30fe8aeea372101e0b5502 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Thu, 19 Apr 2018 08:29:59 +0200 Subject: Add Choice.direct_dep field Same as Symbol.direct_dep (OR of node dependencies from all definition locations). It's handy to have available when generating information about choices. --- kconfiglib.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'kconfiglib.py') diff --git a/kconfiglib.py b/kconfiglib.py index 487fd56..e014481 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -1963,14 +1963,18 @@ class Kconfig(object): name = self._next_token() if name is None: choice = Choice() + choice.direct_dep = self.n + self._choices.append(choice) else: # Named choice choice = self.named_choices.get(name) if not choice: choice = Choice() - self._choices.append(choice) choice.name = name + choice.direct_dep = self.n + + self._choices.append(choice) self.named_choices[name] = choice choice.kconfig = self @@ -2266,10 +2270,9 @@ class Kconfig(object): else node.parent.dep) if isinstance(node.item, (Symbol, Choice)): - if isinstance(node.item, Symbol): - # See the class documentation - node.item.direct_dep = \ - self._make_or(node.item.direct_dep, node.dep) + # See the Symbol/Choice class documentation + node.item.direct_dep = \ + self._make_or(node.item.direct_dep, node.dep) # Set the prompt, with dependencies propagated if node.prompt: @@ -3547,6 +3550,9 @@ class Choice(object): Note that 'depends on' and parent dependencies are propagated to 'default' conditions. + direct_dep: + See Symbol.direct_dep. + is_optional: True if the choice has the 'optional' flag set on it and can be in n mode. @@ -3561,6 +3567,7 @@ class Choice(object): "_dependents", "_was_set", "defaults", + "direct_dep", "is_constant", "is_optional", "kconfig", @@ -3758,6 +3765,7 @@ class Choice(object): """ # These attributes are always set on the instance from outside and # don't need defaults: + # direct_dep # kconfig self.orig_type = UNKNOWN -- cgit v1.2.3