Patchwork [bitbake-devel,2/2] bitbake: add -C option to invalidate a task and rebuild the target

mail settings
Submitter Paul Eggleton
Date June 18, 2012, 3:45 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/30055/
State New
Headers show


Paul Eggleton - June 18, 2012, 3:45 p.m.
This new command line option forces the specified task and all dependent
tasks up to the default task to re-run. This means that the following
single step:

bitbake -C compile somerecipe

is equivalent to the following two steps (with the recent change to -f):

bitbake -c compile -f somerecipe
bitbake somerecipe

Note that to work this option needs full hashing enabled (i.e.
BB_SIGNATURE_HANDLER must be set to a signature handler that inherits
from BasicHash). If this is not the case, -C effectively does nothing.

Based on a previous implementation of this option by Jason Wessel

Implements [YOCTO #2615].

Signed-off-by: Paul Eggleton <>
 bitbake/bin/bitbake        |    3 +++
 bitbake/lib/bb/ |   20 ++++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)


diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
index 478ac06..f23673f 100755
--- a/bitbake/bin/bitbake
+++ b/bitbake/bin/bitbake
@@ -118,6 +118,9 @@  Default BBFILES are the .bb files in the current directory.""")
     parser.add_option("-c", "--cmd", help = "Specify task to execute. Note that this only executes the specified task for the providee and the packages it depends on, i.e. 'compile' does not implicitly call stage for the dependencies (IOW: use only if you know what you are doing). Depending on the base.bbclass a listtasks tasks is defined and will show available tasks",
                action = "store", dest = "cmd")
+    parser.add_option("-C", "--clear-stamp", help = "Invalidate the specified stamp for a task such as 'compile' and run the default task for the specified target(s)",
+                action = "store", dest = "invalidate_stamp")
     parser.add_option("-r", "--read", help = "read the specified file before bitbake.conf",
                action = "append", dest = "prefile", default = [])
diff --git a/bitbake/lib/bb/ b/bitbake/lib/bb/
index 28eb072..608aff8 100644
--- a/bitbake/lib/bb/
+++ b/bitbake/lib/bb/
@@ -705,11 +705,27 @@  class RunQueueData:
+        def invalidate_task(fn, taskname, error_nostamp):
+            taskdep = self.dataCache.task_deps[fn]
+            if 'nostamp' in taskdep and taskname in taskdep['nostamp']:
+                if error_nostamp:
+                    bb.fatal("Task %s is marked nostamp, cannot invalidate this task" % taskname)
+                else:
+                    bb.debug(1, "Task %s is marked nostamp, cannot invalidate this task" % taskname)
+            else:
+                logger.verbose("Invalidate task %s, %s", taskname, fn)
+                bb.parse.siggen.invalidate_task(taskname, self.dataCache, fn)
         # Invalidate task if force mode active
         if self.cooker.configuration.force:
             for (fn, target) in self.target_pairs:
-                logger.verbose("Invalidate task %s, %s", target, fn)
-                bb.parse.siggen.invalidate_task(target, self.dataCache, fn)
+                invalidate_task(fn, target, False)
+        # Invalidate task if invalidate mode active
+        if self.cooker.configuration.invalidate_stamp:
+            for (fn, target) in self.target_pairs:
+                for st in self.cooker.configuration.invalidate_stamp.split(','):
+                    invalidate_task(fn, "do_%s" % st, True)
         # Interate over the task list and call into the siggen code
         dealtwith = set()