From a34d788a5e71769785b5c7e2ae66fcf2c87c5ab3 Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Tue, 29 Jan 2019 11:16:25 +0800 Subject: [PATCH] kconfiglib: allow disabling of config override warnings Patches ESP-IDF copy of kconfiglib.py with modifications in commit b65baa47f69ae4c3993876a7edf0da0075aa70ff from kconfiglib repository. --- tools/kconfig_new/kconfiglib.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/tools/kconfig_new/kconfiglib.py b/tools/kconfig_new/kconfiglib.py index 46f845c57..c17b32b4a 100644 --- a/tools/kconfig_new/kconfiglib.py +++ b/tools/kconfig_new/kconfiglib.py @@ -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: