kconfiglib: allow disabling of redundant definition warnings
Patches ESP-IDF copy of kconfiglib.py with modifications in commit 94c63de77c7a3422347e59e168b05174d0b9e84d from kconfiglib repository.
This commit is contained in:
parent
5c88c5996d
commit
d6b5f43ea0
1 changed files with 29 additions and 4 deletions
|
@ -500,6 +500,7 @@ class Kconfig(object):
|
||||||
__slots__ = (
|
__slots__ = (
|
||||||
"_choices",
|
"_choices",
|
||||||
"_print_undef_assign",
|
"_print_undef_assign",
|
||||||
|
"_print_redun_assign",
|
||||||
"_print_warnings",
|
"_print_warnings",
|
||||||
"_set_re_match",
|
"_set_re_match",
|
||||||
"_unset_re_match",
|
"_unset_re_match",
|
||||||
|
@ -575,6 +576,7 @@ class Kconfig(object):
|
||||||
|
|
||||||
self._print_warnings = warn
|
self._print_warnings = warn
|
||||||
self._print_undef_assign = False
|
self._print_undef_assign = False
|
||||||
|
self._print_redun_assign = True
|
||||||
|
|
||||||
self.syms = {}
|
self.syms = {}
|
||||||
self.const_syms = {}
|
self.const_syms = {}
|
||||||
|
@ -826,10 +828,12 @@ class Kconfig(object):
|
||||||
display_val = val
|
display_val = val
|
||||||
display_user_val = sym.user_value
|
display_user_val = sym.user_value
|
||||||
|
|
||||||
self._warn('{} set more than once. Old value: "{}", new '
|
msg = '{} set more than once. Old value: "{}", new value: "{}".'.format(name, display_user_val, display_val)
|
||||||
'value: "{}".'
|
|
||||||
.format(name, display_user_val, display_val),
|
if display_user_val == display_val:
|
||||||
filename, linenr)
|
self._warn_redun_assign(msg, filename, linenr)
|
||||||
|
else:
|
||||||
|
self._warn(msg, filename, linenr)
|
||||||
|
|
||||||
sym.set_value(val)
|
sym.set_value(val)
|
||||||
|
|
||||||
|
@ -1057,6 +1061,19 @@ class Kconfig(object):
|
||||||
"""
|
"""
|
||||||
self._print_undef_assign = False
|
self._print_undef_assign = False
|
||||||
|
|
||||||
|
def enable_redun_warnings(self):
|
||||||
|
"""
|
||||||
|
Enables warnings for redundant assignments to symbols. Printed to
|
||||||
|
stderr. Enabled by default.
|
||||||
|
"""
|
||||||
|
self._print_redun_assign = True
|
||||||
|
|
||||||
|
def disable_redun_warnings(self):
|
||||||
|
"""
|
||||||
|
See enable_redun_warnings().
|
||||||
|
"""
|
||||||
|
self._print_redun_assign = False
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
"""
|
"""
|
||||||
Returns a string with information about the Kconfig object when it is
|
Returns a string with information about the Kconfig object when it is
|
||||||
|
@ -1071,6 +1088,8 @@ class Kconfig(object):
|
||||||
"warnings " + ("enabled" if self._print_warnings else "disabled"),
|
"warnings " + ("enabled" if self._print_warnings else "disabled"),
|
||||||
"undef. symbol assignment warnings " +
|
"undef. symbol assignment warnings " +
|
||||||
("enabled" if self._print_undef_assign else "disabled"),
|
("enabled" if self._print_undef_assign else "disabled"),
|
||||||
|
"redundant symbol assignment warnings " +
|
||||||
|
("enabled" if self._print_redun_assign else "disabled")
|
||||||
)))
|
)))
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -2150,6 +2169,12 @@ class Kconfig(object):
|
||||||
'attempt to assign the value "{}" to the undefined symbol {}' \
|
'attempt to assign the value "{}" to the undefined symbol {}' \
|
||||||
.format(val, name), filename, linenr)
|
.format(val, name), filename, linenr)
|
||||||
|
|
||||||
|
def _warn_redun_assign(self, msg, filename=None, linenr=None):
|
||||||
|
"""
|
||||||
|
See the class documentation.
|
||||||
|
"""
|
||||||
|
if self._print_redun_assign:
|
||||||
|
_stderr_msg("warning: " + msg, filename, linenr)
|
||||||
|
|
||||||
class Symbol(object):
|
class Symbol(object):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue