summaryrefslogtreecommitdiff
path: root/examples/oldconfig.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-02-06 04:45:07 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2018-02-06 04:56:23 +0100
commit17d7568c6da9452ee0612e29edceee70017585d1 (patch)
tree7d6a3d579039dee1dd6b2d2a760ab86969d2522b /examples/oldconfig.py
parent66058f3a3d4ac3b63861d8574be753eece44779e (diff)
Account for earlier symbols depending on later ones in oldconfig.py
The oldnoconfig operation needs to be rerun if the value of any symbol changes, to catch cases where symbols depend on symbols defined after them. Otherwise the earlier symbols will just get their default value instead of being prompted for.
Diffstat (limited to 'examples/oldconfig.py')
-rw-r--r--examples/oldconfig.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/examples/oldconfig.py b/examples/oldconfig.py
index 3cb60f0..d4eec97 100644
--- a/examples/oldconfig.py
+++ b/examples/oldconfig.py
@@ -146,6 +146,9 @@ def do_oldconfig_for_node(node):
Prompts the user for a value for the menu node item, where applicable in
oldconfig mode
"""
+ # See do_oldconfig()
+ global conf_changed
+
# Only symbols and choices can be configured
if not isinstance(node.item, (Symbol, Choice)):
return
@@ -198,10 +201,16 @@ def do_oldconfig_for_node(node):
if sym.type == HEX and not val.startswith(("0x", "0X")):
val = "0x" + val
+ old_str_val = sym.str_value
+
# Kconfiglib itself will print a warning here if the value
# is invalid, so we don't need to bother
if sym.set_value(val):
# Valid value input. We're done with this node.
+
+ if sym.str_value != old_str_val:
+ conf_changed = True
+
return
else:
@@ -253,15 +262,32 @@ def do_oldconfig_for_node(node):
continue
# Valid selection
+
+ if options[sel_index - 1].tri_value != 2:
+ conf_changed = True
+
options[sel_index - 1].set_value(2)
return
def do_oldconfig(node):
+ # An earlier symbol in the Kconfig files might depend on a later symbol and
+ # become visible if its value changes. This flag is set to True if the
+ # value of any symbol changes, in which case we rerun the oldconfig to
+ # check for new visible symbols.
+ global conf_changed
+
+ while True:
+ conf_changed = False
+ do_oldconfig_rec(node)
+ if not conf_changed:
+ break
+
+def do_oldconfig_rec(node):
while node:
do_oldconfig_for_node(node)
if node.list:
- do_oldconfig(node.list)
+ do_oldconfig_rec(node.list)
node = node.next