menuconfig: Improve behavior for named choices included multiple times

Update menuconfig to upstream revision 38dff36b0f97b, to improve the
behavior for a case reported by Øyvind Rønningstad.

Upstream commit message:

    menuconfig: Only list duplicated choice symbols once

    When a Kconfig file defined a named choice and was included multiple
    times, the choice symbols were listed multiple times in the
    menuconfig as well (due to commit 17d7c1e ("menuconfig: Show all
    symbols at each menu location for multi.def. choices")).

    That's probably not what you want. Tweak it so that each symbol is
    only shown once, with the prompt that was used for it at whatever
    choice definition location is entered.

    Also change how the choice selection is displayed before the choice
    is entered, so that the prompt used for the selected symbol at that
    particular location is used. Previously, the prompt at the first
    definition location for the symbol was always used.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
This commit is contained in:
Ulf Magnusson 2018-11-28 15:15:56 +01:00 committed by Carles Cufí
commit c1f4d677f2

View file

@ -1421,9 +1421,23 @@ def _shown_nodes(menu):
# #
# Note: Named choices are pretty broken in the C tools, and this is # Note: Named choices are pretty broken in the C tools, and this is
# super obscure, so you probably won't find much that relies on this. # super obscure, so you probably won't find much that relies on this.
return [node
for choice_node in menu.item.nodes # Do some additional work to avoid listing choice symbols twice if all
for node in rec(choice_node.list)] # or part of the choice is copied in multiple locations (e.g. by
# including some Kconfig file multiple times). We give the prompts at
# the current location precedence.
seen_syms = {node.item for node in rec(menu.list)
if isinstance(node.item, Symbol)}
res = []
for choice_node in menu.item.nodes:
for node in rec(choice_node.list):
# 'choice_node is menu' checks if we're dealing with the
# current location
if node.item not in seen_syms or choice_node is menu:
res.append(node)
if isinstance(node.item, Symbol):
seen_syms.add(node.item)
return res
return rec(menu.list) return rec(menu.list)
@ -2791,9 +2805,19 @@ def _node_str(node):
# choices in y mode # choices in y mode
sym = node.item.selection sym = node.item.selection
if sym: if sym:
for node_ in sym.nodes: for sym_node in sym.nodes:
if node_.prompt: # Use the prompt used at this choice location, in case the
s += " ({})".format(node_.prompt[0]) # choice symbol is defined in multiple locations
if sym_node.parent is node and sym_node.prompt:
s += " ({})".format(sym_node.prompt[0])
break
else:
# If the symbol isn't defined at this choice location, then
# just use whatever prompt we can find for it
for sym_node in sym.nodes:
if sym_node.prompt:
s += " ({})".format(sym_node.prompt[0])
break
# Print "--->" next to nodes that have menus that can potentially be # Print "--->" next to nodes that have menus that can potentially be
# entered. Print "----" if the menu is empty. We don't allow those to be # entered. Print "----" if the menu is empty. We don't allow those to be