diff mbox series

[5/7] tinfoil: add a prepared task runner

Message ID 20260815134722.497586-6-adrian.freihofer@siemens.com
State New
Headers show
Series cooker/tinfoil: fix -b bbappend handling and add single-task prepared-task API | expand

Commit Message

AdrianF Aug. 15, 2026, 1:46 p.m. UTC
From: Adrian Freihofer <adrian.freihofer@siemens.com>

Add run_prepared_task() to execute a single recipe task, and nothing
else. No dependencies are resolved and no other task of the recipe is
run, so everything the task consumes must already be in place. It uses
BitBake's normal worker path, retaining the standard dispatch for shell
and Python task bodies as well as fakeroot setup.

devtool ide-sdk needs to rerun an already prepared BitBake task after a
developer changes its source. A normal target build would create a
runqueue and resolve dependencies again, and even "bitbake -b" would
re-run the task's intra-recipe predecessors. That is wrong for this
workflow: the developer intentionally wants to rerun only the prepared
task against content the IDE has just produced. Expose the single-task
worker path so devtool can reuse it instead of maintaining a separate
task executor and pseudo-session setup.

AI-Generated: Uses GitHub Copilot

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 lib/bb/tinfoil.py | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/lib/bb/tinfoil.py b/lib/bb/tinfoil.py
index 634d7796f..42385c879 100644
--- a/lib/bb/tinfoil.py
+++ b/lib/bb/tinfoil.py
@@ -826,20 +826,39 @@  class Tinfoil:
             else:
                 return None
 
-    def build_file(self, buildfile, task, internal=True):
+    def build_file(self, buildfile, task, internal=True, taskonly=False):
         """
         Runs the specified task for just a single recipe (i.e. no dependencies).
         This is equivalent to bitbake -b, except with the default internal=True
         no warning about dependencies will be produced, normal info messages
         from the runqueue will be silenced and BuildInit, BuildStarted and
         BuildCompleted events will not be fired.
+        With taskonly=True the recipe's own task ordering is dropped as well, so
+        only the requested task runs.
         """
-        return self.run_command('buildFile', buildfile, task, internal)
+        return self.run_command('buildFile', buildfile, task, internal, taskonly)
 
     @wait_for
     def build_file_sync(self, *args):
         self.build_file(*args)
 
+    def run_prepared_task(self, recipe, task):
+        """Run *task* for one parsed recipe, and nothing else.
+
+        No dependencies are resolved and no other task of the recipe is run,
+        so everything the task consumes must already be in place. The task
+        runs through the normal BitBake worker path, including fakeroot setup
+        and dispatch of shell or Python task bodies.
+
+        The task is forced to execute rather than being skipped as up to date.
+        Returns False if the task failed.
+        """
+        self.run_command('setConfig', 'force', True)
+        try:
+            return self.build_file_sync(self.get_recipe_file(recipe), task, True, True)
+        finally:
+            self.run_command('setConfig', 'force', False)
+
     def build_targets(self, targets, task=None, handle_events=True, extra_events=None, event_callback=None):
         """
         Builds the specified targets. This is equivalent to a normal invocation