From: Simon Glass <simon.glass@canonical.com>
Split the setup logic into _collect_defconfigs() for gathering defconfig
file paths and _start_scanners() for spawning the parallel scan
processes. This reduces complexity and eliminates the too-many-locals
warning.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
tools/buildman/boards.py | 60 ++++++++++++++++++++++++++++++----------
1 file changed, 46 insertions(+), 14 deletions(-)
@@ -785,25 +785,15 @@ class Boards:
params_list.append(params)
warnings.update(warn)
- def scan_defconfigs(self, config_dir, srcdir, jobs=1, warn_targets=False):
- """Collect board parameters for all defconfig files.
-
- This function invokes multiple processes for faster processing.
+ @staticmethod
+ def _collect_defconfigs(config_dir):
+ """Collect all defconfig files from a directory
Args:
config_dir (str): Directory containing the defconfig files
- srcdir (str): Directory containing source code (Kconfig files)
- jobs (int): The number of jobs to run simultaneously
- warn_targets (bool): True to warn about missing or duplicate
- CONFIG_TARGET options
Returns:
- tuple:
- list of dict: List of board parameters, each a dict:
- key: 'arch', 'cpu', 'soc', 'vendor', 'board', 'target',
- 'config'
- value: string value of the key
- list of str: List of warnings recorded
+ list of str: Paths to all defconfig files found
"""
all_defconfigs = []
for (dirpath, _, filenames) in os.walk(config_dir):
@@ -811,7 +801,23 @@ class Boards:
if fnmatch.fnmatch(filename, '.*'):
continue
all_defconfigs.append(os.path.join(dirpath, filename))
+ return all_defconfigs
+
+ def _start_scanners(self, all_defconfigs, srcdir, jobs, warn_targets):
+ """Start parallel defconfig scanning processes
+
+ Args:
+ all_defconfigs (list of str): Paths to defconfig files to scan
+ srcdir (str): Directory containing source code (Kconfig files)
+ jobs (int): The number of jobs to run simultaneously
+ warn_targets (bool): True to warn about missing or duplicate
+ CONFIG_TARGET options
+ Returns:
+ tuple:
+ list of Process: Running scanner processes
+ list of Queue: Queues for receiving results
+ """
total_boards = len(all_defconfigs)
processes = []
queues = []
@@ -826,6 +832,32 @@ class Boards:
processes.append(proc)
queues.append(que)
+ return processes, queues
+
+ def scan_defconfigs(self, config_dir, srcdir, jobs=1, warn_targets=False):
+ """Collect board parameters for all defconfig files.
+
+ This function invokes multiple processes for faster processing.
+
+ Args:
+ config_dir (str): Directory containing the defconfig files
+ srcdir (str): Directory containing source code (Kconfig files)
+ jobs (int): The number of jobs to run simultaneously
+ warn_targets (bool): True to warn about missing or duplicate
+ CONFIG_TARGET options
+
+ Returns:
+ tuple:
+ list of dict: List of board parameters, each a dict:
+ key: 'arch', 'cpu', 'soc', 'vendor', 'board', 'target',
+ 'config'
+ value: string value of the key
+ list of str: List of warnings recorded
+ """
+ all_defconfigs = self._collect_defconfigs(config_dir)
+ processes, queues = self._start_scanners(all_defconfigs, srcdir, jobs,
+ warn_targets)
+
# The resulting data should be accumulated to these lists
params_list = []
warnings = set()