summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/merge_config.py29
-rw-r--r--examples/oldconfig.py4
2 files changed, 23 insertions, 10 deletions
diff --git a/examples/merge_config.py b/examples/merge_config.py
index bc6e4b8..a6110f8 100644
--- a/examples/merge_config.py
+++ b/examples/merge_config.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python3
-#
# This script functions similarly to scripts/kconfig/merge_config.sh from the
# kernel tree, merging multiple configurations fragments to produce a complete
# .config, with unspecified values filled in as for alldefconfig.
@@ -37,7 +35,7 @@
# conf3 contents:
#
# # Ops... assigned twice
-# CONFIG_FOO is not set
+# # CONFIG_FOO is not set
#
# Ops... this symbol doesn't exist
# CONFIG_OPS=y
@@ -52,13 +50,13 @@
#
# Running:
#
-# $ ./merge_config.py Kconfig merged conf1 conf2 conf3 conf4
-# conf3:2: warning: FOO set more than once. Old value: "y", new value: "n".
+# $ python(3) merge_config.py Kconfig merged conf1 conf2 conf3 conf4
+# conf3:2: warning: FOO (defined at Kconfig:1) set more than once. Old value: "y", new value: "n".
# conf3:5: warning: attempt to assign the value "y" to the undefined symbol OPS
-# warning: QAZ was assigned the value "y" but got the value "n" -- check dependencies
+# warning: QAZ (defined at Kconfig:10) was assigned the value "y" but got the value "n" -- check dependencies
# $ cat merged
# Generated by Kconfiglib (https://github.com/ulfalizer/Kconfiglib)
-# CONFIG_FOO is not set
+# # CONFIG_FOO is not set
# CONFIG_BAR=y
# CONFIG_BAZ="baz string"
from kconfiglib import Kconfig, Symbol, BOOL, TRISTATE, TRI_TO_STR
@@ -86,6 +84,21 @@ kconf.write_config(sys.argv[2])
# Print warnings for symbols whose actual value doesn't match the assigned
# value
+
+def name_and_loc_str(sym):
+ """
+ Helper for printing the symbol name along with the location(s) in the
+ Kconfig files where the symbol is defined
+ """
+ # If the symbol has no menu nodes, it is undefined
+ if not sym.nodes:
+ return sym.name + " (undefined)"
+
+ return "{} (defined at {})".format(
+ sym.name,
+ ", ".join("{}:{}".format(node.filename, node.linenr)
+ for node in sym.nodes))
+
for sym in kconf.defined_syms:
# Was the symbol assigned to?
if sym.user_value is not None:
@@ -99,4 +112,4 @@ for sym in kconf.defined_syms:
if user_value != sym.str_value:
print('warning: {} was assigned the value "{}" but got the '
'value "{}" -- check dependencies'
- .format(sym.name, user_value, sym.str_value))
+ .format(name_and_loc_str(sym), user_value, sym.str_value))
diff --git a/examples/oldconfig.py b/examples/oldconfig.py
index aa8e253..737ddae 100644
--- a/examples/oldconfig.py
+++ b/examples/oldconfig.py
@@ -60,7 +60,7 @@
#
# $ touch .config # Run with empty .config
#
-# $ python oldconfig.py Kconfig
+# $ python(3) oldconfig.py Kconfig
# BOOL_SYM prompt (BOOL_SYM, defined at Kconfig:5) [n/Y] foo
# Invalid tristate value
# BOOL_SYM prompt (BOOL_SYM, defined at Kconfig:5) [n/Y] n
@@ -118,7 +118,7 @@ def print_help(node):
def name_and_loc_str(sym):
"""
Helper for printing the symbol name along with the location(s) in the
- Kconfig files where it is defined
+ Kconfig files where the symbol is defined
"""
return "{}, defined at {}".format(
sym.name,