]> granicus.if.org Git - esp-idf/commitdiff
tools: Don't use backslashes in Kconfigs and ignore long lines to avoid errors
authorRoland Dobai <dobai.roland@gmail.com>
Thu, 31 Jan 2019 13:10:14 +0000 (14:10 +0100)
committerRoland Dobai <dobai.roland@gmail.com>
Fri, 1 Feb 2019 10:33:41 +0000 (11:33 +0100)
Closes https://github.com/espressif/esp-idf/issues/3012

components/bt/Kconfig
components/esp32/Kconfig
tools/check_kconfigs.py
tools/test_check_kconfigs.py

index 2638f1fa8c461412fdf4e258586a8e5db879f329..4551a47f88148ca574739a2be5235a9711393f2e 100644 (file)
@@ -60,14 +60,12 @@ menu Bluetooth
 
         config BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN_EFF
             int
-            default \
-                BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN if BTDM_CONTROLLER_MODE_BR_EDR_ONLY || BTDM_CONTROLLER_MODE_BTDM
+            default BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN if BTDM_CONTROLLER_MODE_BR_EDR_ONLY || BTDM_CONTROLLER_MODE_BTDM  # NOERROR
             default 0
 
         config BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN_EFF
             int
-            default \
-                BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN if BTDM_CONTROLLER_MODE_BR_EDR_ONLY || BTDM_CONTROLLER_MODE_BTDM
+            default BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN if BTDM_CONTROLLER_MODE_BR_EDR_ONLY || BTDM_CONTROLLER_MODE_BTDM  # NOERROR
             default 0
 
         choice BTDM_CONTROLLER_PINNED_TO_CORE_CHOICE
index be7792655fb5055c8c05ab83ef6e1a1e04175abb..aecd26a6555314740a442548c63c0b4917aae3ff 100644 (file)
@@ -806,8 +806,7 @@ menu "ESP32-specific"
         int "Number of cycles for RTC_SLOW_CLK calibration"
         default 3000 if ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL
         default 1024 if ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC
-        range 0 27000 if ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL || ESP32_RTC_CLOCK_SOURCE_EXTERNAL_OSC \
-            || ESP32_RTC_CLOCK_SOURCE_INTERNAL_8MD256
+        range 0 27000 if ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL || ESP32_RTC_CLOCK_SOURCE_EXTERNAL_OSC || ESP32_RTC_CLOCK_SOURCE_INTERNAL_8MD256  # NOERROR
         range 0 32766 if ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC
         help
             When the startup code initializes RTC_SLOW_CLK, it can perform
index 412aa2c2f07eeba0137ffaf53d3f78b65f77d5c7..b65f68cda58b2c8d4b62e48894aca360d736f547 100755 (executable)
@@ -44,12 +44,19 @@ CONFIG_NAME_MAX_LENGTH = 60
 # TODO increase prefix length (after the names have been refactored)
 CONFIG_NAME_MIN_PREFIX_LENGTH = 0
 
+# The checker will not fail if it encounters this string (it can be used for temporarily resolve conflicts)
+RE_NOERROR = re.compile(r'\s+#\s+NOERROR\s+$')
+
 # list or rules for lines
 LINE_ERROR_RULES = [
     # (regular expression for finding,      error message,                                  correction)
     (re.compile(r'\t'),                     'tabulators should be replaced by spaces',      r' ' * SPACES_PER_INDENT),
     (re.compile(r'\s+\n'),                  'trailing whitespaces should be removed',       r'\n'),
     (re.compile(r'.{120}'),                 'line should be shorter than 120 characters',   None),
+    # "\<CR><LF>" is not recognized due to a bug in tools/kconfig/zconf.l. The bug was fixed but the rebuild of
+    # mconf-idf is not enforced and an incorrect version is supplied with all previous IDF versions. Backslashes
+    # cannot be enabled unless everybody updates mconf-idf.
+    (re.compile(r'\\\n'),                   'line cannot be wrapped by backslash',          None),
 ]
 
 
@@ -81,11 +88,17 @@ class LineRuleChecker(BaseChecker):
     checks LINE_ERROR_RULES for each line
     """
     def process_line(self, line, line_number):
+        suppress_errors = RE_NOERROR.search(line) is not None
         errors = []
         for rule in LINE_ERROR_RULES:
             m = rule[0].search(line)
             if m:
-                errors.append(rule[1])
+                if suppress_errors:
+                    # just print but no failure
+                    e = InputError(self.path_in_idf, line_number, rule[1], line)
+                    print(e)
+                else:
+                    errors.append(rule[1])
                 if rule[2]:
                     line = rule[0].sub(rule[2], line)
         if len(errors) > 0:
@@ -297,11 +310,10 @@ class IndentAndNameChecker(BaseChecker):
                     self.force_next_indent = 0
                 return
 
-        else:
-            if stripped_line.endswith('\\') and stripped_line.startswith(('config', 'menuconfig', 'choice')):
-                raise InputError(self.path_in_idf, line_number,
-                                 'Line-wrap with backslash is not supported here',
-                                 line)  # no suggestion for this
+        elif stripped_line.endswith('\\') and stripped_line.startswith(('config', 'menuconfig', 'choice')):
+            raise InputError(self.path_in_idf, line_number,
+                             'Line-wrap with backslash is not supported here',
+                             line)  # no suggestion for this
 
         self.check_name_and_update_prefix(stripped_line, line_number)
 
index 866d1d82859f0707ea87617d522768095d8d9417..737ae46570ecc3dd85fd9b83f9ccfbc13e80cea8 100755 (executable)
@@ -67,6 +67,9 @@ class TestLineRuleChecker(unittest.TestCase, ApplyLine):
         self.expt_success('x' * 119)
         self.expt_success('')
 
+    def test_backslashes(self):
+        self.expect_error('test \\', expect=None)
+
 
 class TestIndentAndNameChecker(unittest.TestCase, ApplyLine):
     def setUp(self):
@@ -153,15 +156,6 @@ class TestIndent(TestIndentAndNameChecker):
         self.expt_success('config')
         self.expt_success('    help')
 
-    def test_backslashes(self):
-        self.expt_success('default \\')
-        self.expect_error('help', expect=None)
-        self.expt_success('    CONFIG')
-        self.expt_success('default \\')
-        self.expt_success('    LINE1\\')
-        self.expt_success('    LINE2')
-        self.expt_success('help')
-
 
 class TestName(TestIndentAndNameChecker):
     def setUp(self):
@@ -181,11 +175,6 @@ class TestName(TestIndentAndNameChecker):
         self.expect_error('    choice ' + ('X' * too_long), expect=None)
         self.expt_success('endmenu')
 
-    def test_config_backslash(self):
-        self.expect_error('config\\', expect=None)
-        self.expect_error('menuconfig\\', expect=None)
-        self.expect_error('choice\\', expect=None)
-
 
 class TestPrefix(TestIndentAndNameChecker):
     def test_prefix_len(self):