[Concept,07/20] buildman: Add thread_class param to Builder

Message ID 20260316154733.1587261-8-sjg@u-boot.org
State New
Headers
Series buildman: Add distributed builds |

Commit Message

Simon Glass March 16, 2026, 3:47 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

The distributed-build worker needs a custom BuilderThread subclass that
sends results over SSH instead of writing to disk.

Add a thread_class parameter to Builder.__init__() so the caller can
override the thread class used in _setup_threads()

The default is builderthread.BuilderThread

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

 tools/buildman/builder.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
  

Patch

diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index f704cc86943..f64331d0fb1 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -230,7 +230,8 @@  class Builder:
                  force_build_failures=False, kconfig_check=True,
                  force_reconfig=False,
                  in_tree=False, force_config_on_failure=False, make_func=None,
-                 dtc_skip=False, build_target=None):
+                 dtc_skip=False, build_target=None,
+                 thread_class=builderthread.BuilderThread):
         """Create a new Builder object
 
         Args:
@@ -284,6 +285,10 @@  class Builder:
             make_func (function): Function to call to run 'make'
             dtc_skip (bool): True to skip building dtc and use the system one
             build_target (str): Build target to use (None to use the default)
+            thread_class (type): BuilderThread subclass to use (default
+                builderthread.BuilderThread). This allows the caller to
+                override how results are processed, e.g. sending over SSH
+                instead of writing to disk.
         """
         self.toolchains = toolchains
         self.base_dir = base_dir
@@ -367,6 +372,7 @@  class Builder:
 
         # Note: baseline state for result summaries is now in ResultHandler
 
+        self._thread_class = thread_class
         self._setup_threads(mrproper, per_board_out_dir, test_thread_exceptions)
 
         ignore_lines = ['(make.*Waiting for unfinished)',
@@ -392,7 +398,7 @@  class Builder:
             self.queue = queue.Queue()
             self.out_queue = queue.Queue()
             for i in range(self._num_threads):
-                t = builderthread.BuilderThread(
+                t = self._thread_class(
                         self, i, mrproper, per_board_out_dir,
                         test_exception=test_thread_exceptions)
                 t.daemon = True
@@ -404,7 +410,7 @@  class Builder:
             t.start()
             self._threads.append(t)
         else:
-            self._single_builder = builderthread.BuilderThread(
+            self._single_builder = self._thread_class(
                 self, -1, mrproper, per_board_out_dir)
 
     def __del__(self):