diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2017-10-25 13:35:31 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2017-10-25 13:39:41 +0200 |
| commit | 463cebd7f8bf26673732bf5afcd113ee5e2268b7 (patch) | |
| tree | f29b3a987a49cf4135d0968c971fb259bd1594e8 /examples | |
| parent | dd0e227216e247d2040cdd40bf7397702880cdc4 (diff) | |
Backup
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/allnoconfig.py | 35 | ||||
| -rw-r--r-- | examples/allyesconfig.py | 4 | ||||
| -rw-r--r-- | examples/help_grep.py | 2 | ||||
| -rw-r--r-- | examples/print_tree.py | 2 |
4 files changed, 24 insertions, 19 deletions
diff --git a/examples/allnoconfig.py b/examples/allnoconfig.py index edc473d..8d41912 100644 --- a/examples/allnoconfig.py +++ b/examples/allnoconfig.py @@ -12,7 +12,7 @@ from kconfiglib import Config, Symbol, tri_less import sys def do_allnoconfig(node): - global no_changes + global changed # Walk the tree of menu nodes. You can imagine this as going down/into menu # entries in the menuconfig interface, setting each to 'n' (or the lowest @@ -22,14 +22,16 @@ def do_allnoconfig(node): if isinstance(node.item, Symbol): sym = node.item - # Is the symbol a non-choice symbol that can be set to a lower - # value than its current value? - if sym.choice is None and sym.assignable and \ - tri_less(sym.assignable[0], sym.value): + # Is the symbol a non-choice, non-allnoconfig_y symbol that can be + # set to a lower value than its current value? + if (sym.choice is None and + not sym.is_allnoconfig_y and + sym.assignable and + tri_less(sym.assignable[0], sym.value)): # Yup, lower it sym.set_value(sym.assignable[0]) - no_changes = False + changed = True # Recursively lower children if node.list is not None: @@ -39,19 +41,22 @@ def do_allnoconfig(node): conf = Config(sys.argv[1]) +# Do an initial pass to set 'option allnoconfig_y' symbols to 'y' +for sym in conf.defined_syms: + if sym.is_allnoconfig_y: + sym.set_value("y") + while 1: - # For tricky dependencies involving '!', setting later symbols to 'n' might - # actually raise the value of earlier symbols. To be super safe, we do - # additional passes until a pass no longer changes the value of any symbol. - # - # This isn't actually needed for any ARCH in the kernel as of 4.14. A - # single pass gives the correct result. - no_changes = True + # Changing later symbols in the configuration can sometimes allow earlier + # symbols to be lowered, e.g. if a later symbol 'select's an earlier + # symbol. To handle such situations, we do additional passes over the tree + # until we're no longer able to change the value of any symbol in a pass. + changed = False - do_allnoconfig(conf.top_menu) + do_allnoconfig(conf.top_node) # Did the pass change any symbols? - if no_changes: + if not changed: break conf.write_config(".config") diff --git a/examples/allyesconfig.py b/examples/allyesconfig.py index 4847c05..32b302c 100644 --- a/examples/allyesconfig.py +++ b/examples/allyesconfig.py @@ -27,7 +27,7 @@ conf = Config(sys.argv[1]) # tree can be walked iteratively by using the parent pointers. choices = [] -node = conf.top_menu +node = conf.top_node while 1: if isinstance(node.item, Choice): @@ -85,7 +85,7 @@ while 1: # Does the choice have a default selection that we haven't already # selected? if selection is not None and \ - selection is not choice.user_value: + selection is not choice.user_selection: # Yup, select it selection.set_value("y") diff --git a/examples/help_grep.py b/examples/help_grep.py index fed1731..6fcb08f 100644 --- a/examples/help_grep.py +++ b/examples/help_grep.py @@ -69,4 +69,4 @@ def search_tree(node): node = node.next conf = Config(sys.argv[1]) -search_tree(conf.top_menu) +search_tree(conf.top_node) diff --git a/examples/print_tree.py b/examples/print_tree.py index da795c9..8d18ce9 100644 --- a/examples/print_tree.py +++ b/examples/print_tree.py @@ -64,4 +64,4 @@ def print_items(node, indent): node = node.next conf = Config(sys.argv[1]) -print_items(conf.top_menu, 0) +print_items(conf.top_node, 0) |
