[PATCH 4/7] cooker: add a buildFile mode that runs a single task

AdrianF <[email protected]>
Newsgroups org.openembedded.lists.bitbake-devel
Message-ID <[email protected]>
From: Adrian Freihofer <[email protected]>

devtool ide-sdk lets the IDE build directly (e.g. via cmake or meson,
outside of bitbake). do_install still needs bitbake: it needs pseudo,
and it usually does more than the underlying build tool's own install
step (e.g. `cmake --build --target install`) would - packaging-related
fixups the recipe or its classes add on top. It must run as only that
one already-prepared task against the source the developer just edited
- not the whole recipe: predecessors, if they ran again, would
rebuild/overwrite the very output the caller is about to inspect or has
already staged.

Add a taskonly argument to buildFileInternal(), plumbed through the
buildFile command, that also clears the intra-recipe task parents,
leaving the requested task as the runqueue's only entry. Default
unchanged, so "bitbake -b" behaviour is unaffected.

Note that for example:
- buildFileInternal() cannot do this: it drops external dependencies but
  keeps intra-recipe task ordering ('addtask X after Y'), so requesting
  do_install on an unbuilt recipe still pulls in do_fetch, do_unpack,
  do_patch, do_prepare_recipe_sysroot, do_configure and do_compile.
  That's the right default for "bitbake -b", but not here.
- --runonly can't express this either: mark_active() ignores its depth
  argument and recurses over depends, so the whole chain stays active
  regardless.

AI-Generated: Uses GitHub Copilot

Signed-off-by: Adrian Freihofer <[email protected]>
---
 lib/bb/command.py | 6 +++++-
 lib/bb/cooker.py  | 8 +++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/bb/command.py b/lib/bb/command.py
index b57c5d4a3..1b16884fa 100644
--- a/lib/bb/command.py
+++ b/lib/bb/command.py
@@ -622,9 +622,13 @@ class CommandsAsync:
             internal = params[2]
         else:
             internal = False
+        if len(params) > 3:
+            taskonly = params[3]
+        else:
+            taskonly = False
 
         if internal:
-            command.cooker.buildFileInternal(bfile, task, fireevents=False, quietlog=True)
+            command.cooker.buildFileInternal(bfile, task, fireevents=False, quietlog=True, taskonly=taskonly)
         else:
             command.cooker.buildFile(bfile, task)
     buildFile.needcache = False
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 108551a60..0321478d3 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -1368,7 +1368,7 @@ You can also remove the BB_HASHSERVE_UPSTREAM setting, but this may result in si
 
         self.buildFileInternal(buildfile, task)
 
-    def buildFileInternal(self, buildfile, task, fireevents=True, quietlog=False):
+    def buildFileInternal(self, buildfile, task, fireevents=True, quietlog=False, taskonly=False):
         """
         Build the file matching regexp buildfile
         """
@@ -1418,6 +1418,12 @@ You can also remove the BB_HASHSERVE_UPSTREAM setting, but this may result in si
         self.recipecaches[mc].rundeps[fn] = defaultdict(list)
         self.recipecaches[mc].runrecs[fn] = defaultdict(list)
 
+        if taskonly:
+            # Drop the intra-recipe task ordering too ('addtask X after Y'), so
+            # that task is the only entry left in the runqueue.
+            task_deps = self.recipecaches[mc].task_deps[fn]
+            task_deps['parents'] = {t: [] for t in task_deps['tasks']}
+
         bb.parse.siggen.setup_datacache(self.recipecaches)
 
         # Invalidate task for target if force mode active
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.