diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-12-08 04:22:38 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-12-08 04:24:49 +0100 |
| commit | 3cc2f9f32b61ed27c533b60a8544ac32de0d969d (patch) | |
| tree | 931d904414a45ad4dd172f8c9b9c78fc83fb1e7a | |
| parent | 1d69899bf788f939e3c7033c5246643d12584b79 (diff) | |
listnewconfig: Add script
Mirrors 'make listnewconfig' in the C tools.
| -rw-r--r-- | README.rst | 2 | ||||
| -rwxr-xr-x | listnewconfig.py | 43 | ||||
| -rw-r--r-- | setup.py | 2 |
3 files changed, 47 insertions, 0 deletions
@@ -70,6 +70,8 @@ executables. All but one mirror functionality available in the C tools. - `allyesconfig <https://github.com/ulfalizer/Kconfiglib/blob/master/allyesconfig.py>`_ +- `listnewconfig <https://github.com/ulfalizer/Kconfiglib/blob/master/listnewconfig.py>`_ + - `genconfig <https://github.com/ulfalizer/Kconfiglib/blob/master/genconfig.py>`_ ``genconfig`` is intended to be run at build time. It generates a C header from diff --git a/listnewconfig.py b/listnewconfig.py new file mode 100755 index 0000000..bd35502 --- /dev/null +++ b/listnewconfig.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python + +# Copyright (c) 2018, Ulf Magnusson +# SPDX-License-Identifier: ISC + +# Works like 'make listnewconfig', listing all modifiable symbols that are not +# assigned in the configuration file. +# +# The default output filename is '.config'. A different filename can be passed +# in the KCONFIG_CONFIG environment variable. + +import sys + +from kconfiglib import standard_kconfig, BOOL, TRISTATE, INT, HEX, STRING, \ + TRI_TO_STR +import kconfiglib + +def main(): + kconf = standard_kconfig() + kconf.load_config() + for sym in kconf.unique_defined_syms: + # Only show symbols that can be toggled. Choice symbols are a special + # case in that sym.assignable will be (2,) (length 1) for visible + # symbols in choices in y mode, but they can still be toggled by + # selecting some other symbol. + if sym.user_value is None and \ + (len(sym.assignable) > 1 or \ + (sym.visibility and (sym.orig_type in (INT, HEX, STRING) or + sym.choice))): + + # Don't reuse the 'config_string' format for bool/tristate symbols, + # to show n-valued symbols as 'CONFIG_FOO=n' instead of + # '# CONFIG_FOO is not set'. This matches the C tools. + if sym.orig_type in (BOOL, TRISTATE): + s = "{}{}={}\n".format(kconf.config_prefix, sym.name, + TRI_TO_STR[sym.tri_value]) + else: + s = sym.config_string + + sys.stdout.write(s) + +if __name__ == "__main__": + main() @@ -33,6 +33,7 @@ setuptools.setup( "allnoconfig", "allmodconfig", "allyesconfig", + "listnewconfig", ), # TODO: Don't install the menuconfig on Python 2. It won't run there. @@ -47,6 +48,7 @@ setuptools.setup( "allnoconfig = allnoconfig:main", "allmodconfig = allmodconfig:main", "allyesconfig = allyesconfig:main", + "listnewconfig = listnewconfig:main", ) }, |
