summaryrefslogtreecommitdiff
path: root/kconfiglib.py
diff options
context:
space:
mode:
Diffstat (limited to 'kconfiglib.py')
-rw-r--r--kconfiglib.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index c4f20a2..8b2c8e6 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -1307,7 +1307,7 @@ class Kconfig(object):
"within the same choice", loc)
# Set the choice's mode
- sym.choice.set_value(val)
+ sym.choice.set_value(val, loc)
elif sym.orig_type is STRING:
match = _conf_string_match(val)
@@ -1348,7 +1348,7 @@ class Kconfig(object):
if sym._was_set:
self._assigned_twice(sym, val, loc)
- sym.set_value(val)
+ sym.set_value(val, loc)
if replace:
# If we're replacing the configuration, unset the symbols that
@@ -4116,6 +4116,10 @@ class Symbol(object):
most symbols. Undefined and constant symbols have an empty nodes list.
Symbols defined in multiple locations get one node for each location.
+ user_loc:
+ A (filename, linenr) tuple indicating where the user value was set, or
+ None if the user hasn't set a value.
+
choice:
Holds the parent Choice for choice symbols, and None for non-choice
symbols. Doubles as a flag for whether a symbol is a choice symbol.
@@ -4256,6 +4260,7 @@ class Symbol(object):
"ranges",
"rev_dep",
"selects",
+ "user_loc",
"user_value",
"weak_rev_dep",
)
@@ -4549,7 +4554,7 @@ class Symbol(object):
"""
return self.name + " " + _locs(self)
- def set_value(self, value):
+ def set_value(self, value, loc=None):
"""
Sets the user value of the symbol.
@@ -4582,6 +4587,9 @@ class Symbol(object):
Symbol.user_value. Kconfiglib will print a warning by default for
invalid assignments, and set_value() will return False.
+ loc:
+ A (filename, linenr) tuple indicating where the value was set.
+
Returns True if the value is valid for the type of the symbol, and
False otherwise. This only looks at the form of the value. For BOOL and
TRISTATE symbols, check the Symbol.assignable attribute to see what
@@ -4622,6 +4630,7 @@ class Symbol(object):
return False
+ self.user_loc = loc
self.user_value = value
self._was_set = True
@@ -4644,6 +4653,7 @@ class Symbol(object):
gotten a user value via Kconfig.load_config() or Symbol.set_value().
"""
if self.user_value is not None:
+ self.user_loc = None
self.user_value = None
self._rec_invalidate_if_has_prompt()
@@ -4788,6 +4798,7 @@ class Symbol(object):
self.implies = []
self.ranges = []
+ self.user_loc = \
self.user_value = \
self.choice = \
self.env_var = \
@@ -5086,6 +5097,10 @@ class Choice(object):
WARNING: Do not assign directly to this. It will break things. Call
sym.set_value(2) on the choice symbol to be selected instead.
+ user_loc:
+ A (filename, linenr) tuple indicating where the user value was set, or
+ None if the user hasn't set a value.
+
visibility:
See the Symbol class documentation. Acts on the value (mode).
@@ -5156,6 +5171,7 @@ class Choice(object):
"nodes",
"orig_type",
"syms",
+ "user_loc",
"user_selection",
"user_value",
)
@@ -5235,7 +5251,7 @@ class Choice(object):
self._cached_selection = self._selection()
return self._cached_selection
- def set_value(self, value):
+ def set_value(self, value, loc=None):
"""
Sets the user value (mode) of the choice. Like for Symbol.set_value(),
the visibility might truncate the value. Choices without the 'optional'
@@ -5270,6 +5286,7 @@ class Choice(object):
return False
+ self.user_loc = loc
self.user_value = value
self._was_set = True
self._rec_invalidate()
@@ -5282,6 +5299,7 @@ class Choice(object):
the user had never touched the mode or any of the choice symbols.
"""
if self.user_value is not None or self.user_selection:
+ self.user_loc = None
self.user_value = self.user_selection = None
self._rec_invalidate()