]> granicus.if.org Git - esp-idf/commitdiff
kconfiglib: allow disabling of config override warnings
authorRenz Christian Bagaporo <renz@espressif.com>
Tue, 29 Jan 2019 03:16:25 +0000 (11:16 +0800)
committerRenz Christian Bagaporo <renz@espressif.com>
Tue, 29 Jan 2019 12:50:51 +0000 (20:50 +0800)
Patches ESP-IDF copy of kconfiglib.py with modifications in commit
b65baa47f69ae4c3993876a7edf0da0075aa70ff from kconfiglib repository.

tools/kconfig_new/kconfiglib.py

index 46f845c5778c5be74aae29a2f44bc04039be61ac..c17b32b4ab63d52fb9caab6fdfe920013a212290 100644 (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: