Skip to content

Instantly share code, notes, and snippets.

@bartosh
Created October 14, 2015 06:29
Show Gist options
  • Save bartosh/d16606bfe4fd7f6109b7 to your computer and use it in GitHub Desktop.
Save bartosh/d16606bfe4fd7f6109b7 to your computer and use it in GitHub Desktop.
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index a0d7d59..5404f82 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -642,12 +642,10 @@ class BBCooker:
"""
bb.event.fire(bb.event.TreeDataPreparationStarted(), self.data)
- # A task of None means use the default task
- if task is None:
- task = self.configuration.cmd
-
fulltargetlist = self.checkPackages(pkgs_to_build)
+ fulltasrgetlist, task = self.normalize_targets(fulltasrgetlist, task)
+
localdata = data.createCopy(self.data)
bb.data.update_data(localdata)
bb.data.expandKeys(localdata)
@@ -656,15 +654,9 @@ class BBCooker:
current = 0
runlist = []
for k in fulltargetlist:
- ktask = task
- if ":do_" in k:
- k2 = k.split(":do_")
- k = k2[0]
- ktask = k2[1]
+ k, ktask = k.split(":")
taskdata.add_provider(localdata, self.recipecache, k)
current += 1
- if not ktask.startswith("do_"):
- ktask = "do_%s" % ktask
runlist.append([k, ktask])
bb.event.fire(bb.event.TreeDataPreparationProgress(current, len(fulltargetlist)), self.data)
taskdata.add_unresolved(localdata, self.recipecache)
@@ -1252,6 +1244,27 @@ class BBCooker:
raise NoSpecificMatch
return matches[0]
+ def normalize_targets(self, targets, task)
+ """
+ Modify target to always look as <target>:do_<task>
+ """
+ if not task:
+ task = self.configuration.cmd
+
+ if not task.startswith("do_"):
+ task = "do_%s" % task
+
+ result = []
+ for target in targets:
+ if ':' in target:
+ if not ':do_' in target:
+ target = "%s:do_%s" % tuple(target.split(":"))
+ else:
+ target = "%s:%s" % (target, task)
+ result.append(target)
+
+ return result, task
+
def buildFile(self, buildfile, task):
"""
Build the file matching regexp buildfile
@@ -1265,10 +1278,6 @@ class BBCooker:
# buildFile() doesn't use the cache
self.parseConfiguration()
- # If we are told to do the None task then query the default task
- if (task == None):
- task = self.configuration.cmd
-
fn, cls = bb.cache.Cache.virtualfn2realfn(buildfile)
fn = self.matchFile(fn)
@@ -1291,7 +1300,8 @@ class BBCooker:
self.recipecache.add_from_recipeinfo(fn, info_array)
# Tweak some variables
- item = info_array[0].pn
+ targets, task = self.normalize_targets([info_array[0].pn], task)
+ item = targets[0]
self.recipecache.ignored_dependencies = set()
self.recipecache.bbfile_priority[fn] = 1
@@ -1304,8 +1314,6 @@ class BBCooker:
# Invalidate task for target if force mode active
if self.configuration.force:
logger.verbose("Invalidate task %s, %s", task, fn)
- if not task.startswith("do_"):
- task = "do_%s" % task
bb.parse.siggen.invalidate_task(task, self.recipecache, fn)
# Setup taskdata structure
@@ -1316,8 +1324,6 @@ class BBCooker:
bb.event.fire(bb.event.BuildStarted(buildname, [item]), self.expanded_data)
# Execute the runqueue
- if not task.startswith("do_"):
- task = "do_%s" % task
runlist = [[item, task]]
rq = bb.runqueue.RunQueue(self, self.data, self.recipecache, taskdata, runlist)
@@ -1394,6 +1400,9 @@ class BBCooker:
taskdata, runlist, fulltargetlist = self.buildTaskData(targets, task, self.configuration.abort)
buildname = self.data.getVar("BUILDNAME", False)
+
+ fulltargetlist, task = self.normalize_targets(fulltargetlist, task)
+
bb.event.fire(bb.event.BuildStarted(buildname, fulltargetlist), self.data)
rq = bb.runqueue.RunQueue(self, self.data, self.recipecache, taskdata, runlist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment