[Concept,18/29] buildman: Refactor print_size_summary() more in builder.py

Message ID 20260106220403.2915630-19-sjg@u-boot.org
State New
Headers
Series buildman: Clean up builder.py |

Commit Message

Simon Glass Jan. 6, 2026, 10:03 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Extract the architecture size-printing code into _print_arch_size_summary()
to improve readability and reduce complexity in print_size_summary()

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 tools/buildman/builder.py | 55 +++++++++++++++++++++++++--------------
 1 file changed, 35 insertions(+), 20 deletions(-)
  

Patch

diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index 5c33b737740..9d7357b5e06 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -1353,26 +1353,41 @@  class Builder:
                 result['_total_diff'] = total
                 result['_outcome'] = board_dict[result['_target']]
 
-            count = len(target_list)
-            printed_arch = False
-            for name in sorted(totals):
-                diff = totals[name]
-                if diff:
-                    # Display the average difference in this name for this
-                    # architecture
-                    avg_diff = float(diff) / count
-                    color = self.col.RED if avg_diff > 0 else self.col.GREEN
-                    msg = f' {name} {avg_diff:+1.1f}'
-                    if not printed_arch:
-                        tprint(f'{arch:>10s}: (for {count}/{arch_count[arch]} '
-                               'boards)', newline=False)
-                        printed_arch = True
-                    tprint(msg, colour=color, newline=False)
-
-            if printed_arch:
-                tprint()
-                if show_detail:
-                    self.print_size_detail(target_list, show_bloat)
+            self._print_arch_size_summary(arch, target_list, arch_count,
+                                          totals, show_detail, show_bloat)
+
+    def _print_arch_size_summary(self, arch, target_list, arch_count, totals,
+                                 show_detail, show_bloat):
+        """Print size summary for a single architecture
+
+        Args:
+            arch (str): Architecture name
+            target_list (list): List of size-change dicts for this arch
+            arch_count (dict): Dict of arch name to board count
+            totals (dict): Dict of name to total size diff
+            show_detail (bool): Show size delta detail for each board
+            show_bloat (bool): Show detail for each function
+        """
+        count = len(target_list)
+        printed_arch = False
+        for name in sorted(totals):
+            diff = totals[name]
+            if diff:
+                # Display the average difference in this name for this
+                # architecture
+                avg_diff = float(diff) / count
+                color = self.col.RED if avg_diff > 0 else self.col.GREEN
+                msg = f' {name} {avg_diff:+1.1f}'
+                if not printed_arch:
+                    tprint(f'{arch:>10s}: (for {count}/{arch_count[arch]} '
+                           'boards)', newline=False)
+                    printed_arch = True
+                tprint(msg, colour=color, newline=False)
+
+        if printed_arch:
+            tprint()
+            if show_detail:
+                self.print_size_detail(target_list, show_bloat)
 
 
     def print_result_summary(self, board_selected, board_dict, err_lines,