From eb4854f903e31706d2d395d05521424bfa303c0d Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Mon, 16 Sep 2013 22:50:56 +0000 Subject: [PATCH] bitbake: 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] (Bitbake rev: 468c221449290c4f196e87f7d8e23fcd7db86135) Signed-off-by: Alexandru DAMIAN Signed-off-by: Richard Purdie --- bitbake/lib/bb/cooker.py | 71 ++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 42 deletions(-) diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index a07615b04c..988f2cad07 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/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) + taskdata = bb.taskdata.TaskData(abort, skiplist=self.skiplist) + + current = 0 + runlist = [] + for k in fulltargetlist: + taskdata.add_provider(localdata, self.recipecache, k) + current += 1 + 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(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 = bb.taskdata.TaskData(False, skiplist=self.skiplist) + taskdata, runlist, pkgs_to_build = self.buildTaskData(pkgs_to_build, task, False) - runlist = [] - current = 0 - for k in pkgs_to_build: - 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) - taskdata.add_unresolved(localdata, self.recipecache) - bb.event.fire(bb.event.TreeDataPreparationCompleted(len(pkgs_to_build)), self.data) 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() + taskdata, runlist, fulltargetlist = self.buildTaskData(targets, task, self.configuration.abort) + buildname = self.data.getVar("BUILDNAME") - bb.event.fire(bb.event.BuildStarted(buildname, targets), self.data) - - 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) + 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)