summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2013-09-16 22:50:56 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-09-17 14:09:37 +0100
commit468c221449290c4f196e87f7d8e23fcd7db86135 (patch)
tree20ac74aadb52c74d876e5dbd1bdc4fc29e4a84c8
parentcf4a0c7aa82090876ae652b611acfab3ce2688f7 (diff)
downloadbitbake-468c221449290c4f196e87f7d8e23fcd7db86135.tar.gz
cooker: Avoid duplication for taskdata creation
Clean-up to avoid duplication and promote code reuse to factor taskdata creation into a common function. [RP: minor tweaks] Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/cooker.py67
1 files changed, 27 insertions, 40 deletions
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index a07615b04..988f2cad0 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -345,13 +345,7 @@ class BBCooker:
if pkgs_to_build[0] in set(ignore.split()):
bb.fatal("%s is in ASSUME_PROVIDED" % pkgs_to_build[0])
- localdata = data.createCopy(self.data)
- bb.data.update_data(localdata)
- bb.data.expandKeys(localdata)
-
- taskdata = bb.taskdata.TaskData(self.configuration.abort)
- taskdata.add_provider(localdata, self.recipecache, pkgs_to_build[0])
- taskdata.add_unresolved(localdata, self.recipecache)
+ taskdata, runlist, pkgs_to_build = self.buildTaskData(pkgs_to_build, None, self.configuration.abort)
targetid = taskdata.getbuild_id(pkgs_to_build[0])
fnid = taskdata.build_targets[targetid][0]
@@ -383,34 +377,44 @@ class BBCooker:
if data.getVarFlag( e, 'python', envdata ):
logger.plain("\npython %s () {\n%s}\n", e, data.getVar(e, envdata, 1))
- def prepareTreeData(self, pkgs_to_build, task):
+
+ def buildTaskData(self, pkgs_to_build, task, abort):
"""
Prepare a runqueue and taskdata object for iteration over pkgs_to_build
"""
bb.event.fire(bb.event.TreeDataPreparationStarted(), self.data)
- # If we are told to do the None task then query the default task
- if (task == None):
+ # A task of None means use the default task
+ if task is None:
task = self.configuration.cmd
- pkgs_to_build = self.checkPackages(pkgs_to_build)
+ fulltargetlist = self.checkPackages(pkgs_to_build)
localdata = data.createCopy(self.data)
bb.data.update_data(localdata)
bb.data.expandKeys(localdata)
- # We set abort to False here to prevent unbuildable targets raising
- # an exception when we're just generating data
- taskdata = bb.taskdata.TaskData(False, skiplist=self.skiplist)
+ taskdata = bb.taskdata.TaskData(abort, skiplist=self.skiplist)
- runlist = []
current = 0
- for k in pkgs_to_build:
+ runlist = []
+ for k in fulltargetlist:
taskdata.add_provider(localdata, self.recipecache, k)
- runlist.append([k, "do_%s" % task])
current += 1
- bb.event.fire(bb.event.TreeDataPreparationProgress(current, len(pkgs_to_build)), self.data)
+ runlist.append([k, "do_%s" % task])
+ bb.event.fire(bb.event.TreeDataPreparationProgress(current, len(fulltargetlist)), self.data)
taskdata.add_unresolved(localdata, self.recipecache)
- bb.event.fire(bb.event.TreeDataPreparationCompleted(len(pkgs_to_build)), self.data)
+ bb.event.fire(bb.event.TreeDataPreparationCompleted(len(fulltargetlist)), self.data)
+ return taskdata, runlist, fulltargetlist
+
+ def prepareTreeData(self, pkgs_to_build, task):
+ """
+ Prepare a runqueue and taskdata object for iteration over pkgs_to_build
+ """
+
+ # We set abort to False here to prevent unbuildable targets raising
+ # an exception when we're just generating data
+ taskdata, runlist, pkgs_to_build = self.buildTaskData(pkgs_to_build, task, False)
+
return runlist, taskdata
######## WARNING : this function requires cache_extra to be enabled ########
@@ -1073,13 +1077,6 @@ class BBCooker:
Attempt to build the targets specified
"""
- # If we are told to do the NULL task then query the default task
- if (task == None):
- task = self.configuration.cmd
-
- universe = ('universe' in targets)
- targets = self.checkPackages(targets)
-
def buildTargetsIdle(server, rq, abort):
if abort or self.state == state.forceshutdown:
rq.finish_runqueue(True)
@@ -1105,23 +1102,13 @@ class BBCooker:
self.buildSetVars()
- buildname = self.data.getVar("BUILDNAME")
- bb.event.fire(bb.event.BuildStarted(buildname, targets), self.data)
+ taskdata, runlist, fulltargetlist = self.buildTaskData(targets, task, self.configuration.abort)
- localdata = data.createCopy(self.data)
- bb.data.update_data(localdata)
- bb.data.expandKeys(localdata)
-
- taskdata = bb.taskdata.TaskData(self.configuration.abort, skiplist=self.skiplist)
-
- runlist = []
- for k in targets:
- taskdata.add_provider(localdata, self.recipecache, k)
- runlist.append([k, "do_%s" % task])
- taskdata.add_unresolved(localdata, self.recipecache)
+ buildname = self.data.getVar("BUILDNAME")
+ bb.event.fire(bb.event.BuildStarted(buildname, fulltargetlist), self.data)
rq = bb.runqueue.RunQueue(self, self.data, self.recipecache, taskdata, runlist)
- if universe:
+ if 'universe' in targets:
rq.rqdata.warn_multi_bb = True
self.configuration.server_register_idlecallback(buildTargetsIdle, rq)