diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2017-11-09 11:43:13 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2017-11-09 11:43:13 +0100 |
| commit | 395c2db0e9761def8eb992e3e8068ba2d3ab179c (patch) | |
| tree | 7b14ac791dbf9d4b9354f1c6149444e090068309 /examples/allnoconfig_simpler.py | |
| parent | 8c978ee0b9c0f7f8406f58d24478a73330512056 (diff) | |
| parent | 4bffd653148d6fa1c8e626872ae4f445e2b0a24c (diff) | |
Make Kconfiglib 2 official
Merge in the 'kconfiglib-2-backup' branch.
Diffstat (limited to 'examples/allnoconfig_simpler.py')
| -rw-r--r-- | examples/allnoconfig_simpler.py | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/examples/allnoconfig_simpler.py b/examples/allnoconfig_simpler.py index f3cfe9a..81e701c 100644 --- a/examples/allnoconfig_simpler.py +++ b/examples/allnoconfig_simpler.py @@ -1,28 +1,22 @@ # This is a simpler version of allnoconfig.py, corresponding to how the C -# implementation does it. Setting a user value that's not in the assignable -# range of the symbol (between get_lower_bound() and get_upper_bound(), or, -# equivalently, not in get_assignable_values()) is OK; the value will simply -# get truncated downwards or upwards as determined by the visibility and -# selects. +# implementation does it. Verified by the test suite to produce identical +# output to 'make allnoconfig' for all ARCHes. +# +# Usage: +# +# $ make [ARCH=<arch>] scriptconfig SCRIPT=Kconfiglib/examples/allnoconfig_simpler.py -# This version is a bit slower compared allnoconfig.py since Kconfiglib -# invalidates all dependent symbols for each set_user_value() call. This does not -# happen for load_config(), which instead invalidates all symbols once after -# the configuration has been loaded. This is OK for load_config() since nearly -# all symbols will tend to be affected anyway. - -import kconfiglib +from kconfiglib import Kconfig, BOOL, TRISTATE import sys -conf = kconfiglib.Config(sys.argv[1]) +conf = Kconfig(sys.argv[1]) -# Avoid warnings printed by Kconfiglib when assigning a user value with -# set_user_value() to a symbol that has no prompt (such assignments never have -# an effect) -conf.set_print_warnings(False) +# Avoid warnings printed by Kconfiglib when assigning a value to a symbol that +# has no prompt. Such assignments never have an effect. +conf.disable_warnings() -for sym in conf: - if sym.get_type() in (kconfiglib.BOOL, kconfiglib.TRISTATE): - sym.set_user_value("y" if sym.is_allnoconfig_y() else "n") +for sym in conf.defined_syms: + if sym.type in (BOOL, TRISTATE): + sym.set_value(2 if sym.is_allnoconfig_y else 0) conf.write_config(".config") |
