kconfiglib: allow disabling of config override warnings

Patches ESP-IDF copy of kconfiglib.py with modifications in commit
b65baa47f69ae4c3993876a7edf0da0075aa70ff from kconfiglib repository.
This commit is contained in:
Renz Christian Bagaporo 2019-01-29 11:16:25 +08:00
parent 403a24ab64
commit a34d788a5e

View file

@ -500,6 +500,7 @@ class Kconfig(object):
__slots__ = (
"_choices",
"_print_undef_assign",
"_print_override",
"_print_redun_assign",
"_print_warnings",
"_set_re_match",
@ -576,7 +577,7 @@ class Kconfig(object):
self._print_warnings = warn
self._print_undef_assign = False
self._print_redun_assign = True
self._print_redun_assign = self._print_override = True
self.syms = {}
self.const_syms = {}
@ -833,7 +834,7 @@ class Kconfig(object):
if display_user_val == display_val:
self._warn_redun_assign(msg, filename, linenr)
else:
self._warn(msg, filename, linenr)
self._warn_override(msg, filename, linenr)
sym.set_value(val)
@ -1074,6 +1075,23 @@ class Kconfig(object):
"""
self._print_redun_assign = False
def enable_override_warnings(self):
"""
Enables warnings for duplicated assignments in .config files that set
different values (e.g. CONFIG_FOO=m followed by CONFIG_FOO=y, where
the last value set is used).
These warnings are enabled by default. Disabling them might be helpful
in certain cases when merging configurations.
"""
self._print_override = True
def disable_override_warnings(self):
"""
See enable_override_warnings().
"""
self._print_override = False
def __repr__(self):
"""
Returns a string with information about the Kconfig object when it is
@ -2176,6 +2194,13 @@ class Kconfig(object):
if self._print_redun_assign:
_stderr_msg("warning: " + msg, filename, linenr)
def _warn_override(self, msg, filename=None, linenr=None):
"""
See the class documentation.
"""
if self._print_override:
_stderr_msg("warning: " + msg, filename, linenr)
class Symbol(object):
"""
Represents a configuration symbol: