[PATCH v3 15/81] buildman: Correct operation of MAINTAINERS N:

Simon Glass sjg at chromium.org
Sun Jul 16 02:35:43 CEST 2023


This doesn't work as intended. Instead it scans every defconfig file
in the source tree.

Fix it and add a test.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v3:
- Add new patch to correct operation of MAINTAINERS N:

 tools/buildman/boards.py    | 15 ++++++++++-----
 tools/buildman/func_test.py | 17 +++++++++++++----
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/tools/buildman/boards.py b/tools/buildman/boards.py
index 209fb28eccbc..8aea6cf2dea6 100644
--- a/tools/buildman/boards.py
+++ b/tools/buildman/boards.py
@@ -411,12 +411,17 @@ class MaintainersDatabase:
                     walk_path = os.walk(os.path.join(srcdir, 'configs'))
                     for dirpath, _, fnames in walk_path:
                         for cfg in fnames:
-                            path = os.path.join(dirpath, cfg)
+                            path = os.path.join(dirpath, cfg)[len(srcdir) + 1:]
                             front, match, rear = path.partition('configs/')
-                            if not front and match:
-                                front, match, rear = rear.rpartition('_defconfig')
-                                if match and not rear:
-                                    targets.append(front)
+                            if front or not match:
+                                continue
+                            front, match, rear = rear.rpartition('_defconfig')
+
+                            # Use this entry if it matches the defconfig file
+                            # without the _defconfig suffix. For example
+                            # 'am335x.*' matches am335x_guardian_defconfig
+                            if match and not rear and re.fullmatch(rest, front):
+                                targets.append(front)
                 elif line == '\n':
                     add_targets(linenum)
                     targets = []
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index 812b3d8a6777..1994e42d15c8 100644
--- a/tools/buildman/func_test.py
+++ b/tools/buildman/func_test.py
@@ -933,8 +933,8 @@ Active  aarch64     armv8 - armltd total_compute board2
 
         # Move the contents of the second file into this one, removing the
         # second file, to check multiple records in a single file.
-        data = orig_data + tools.read_file(other, binary=False)
-        tools.write_file(main, data, binary=False)
+        both_data = orig_data + tools.read_file(other, binary=False)
+        tools.write_file(main, both_data, binary=False)
         os.remove(other)
         params_list, warnings = self._boards.build_board_list(config_dir, src)
         self.assertEquals(2, len(params_list))
@@ -942,7 +942,7 @@ Active  aarch64     armv8 - armltd total_compute board2
 
         # Add another record, this should be ignored with a warning
         extra = '\n\nAnother\nM: Fred\nF: configs/board9_defconfig\nS: other\n'
-        tools.write_file(main, data + extra, binary=False)
+        tools.write_file(main, both_data + extra, binary=False)
         params_list, warnings = self._boards.build_board_list(config_dir, src)
         self.assertEquals(2, len(params_list))
         self.assertEquals(
@@ -950,7 +950,7 @@ Active  aarch64     armv8 - armltd total_compute board2
              warnings)
 
         # Add another TARGET to the Kconfig
-        tools.write_file(main, data, binary=False)
+        tools.write_file(main, both_data, binary=False)
         orig_kc_data = tools.read_file(kc_file)
         extra = (b'''
 if TARGET_BOARD2
@@ -975,3 +975,12 @@ endif
         self.assertEquals(
             ['WARNING: board2_defconfig: No TARGET_BOARD2 enabled'],
              warnings)
+        tools.write_file(kc_file, orig_kc_data)
+
+        # Replace the last F: line of board 2 with an N: line
+        data = ''.join(both_data.splitlines(keepends=True)[:-1])
+        tools.write_file(main, data + 'N: boa.*2\n', binary=False)
+        params_list, warnings = self._boards.build_board_list(config_dir, src)
+        self.assertEquals(2, len(params_list))
+        self.assertFalse(warnings)
+
-- 
2.41.0.455.g037347b96a-goog



More information about the U-Boot mailing list