summaryrefslogtreecommitdiffstats
path: root/bitbake
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:11:03 +0100
commiteb4854f903e31706d2d395d05521424bfa303c0d (patch)
treecc500878b1754443312255fafb5a363c8dfbe4ee /bitbake
parenta828c898228292c238e42e20d7e254a3f9847082 (diff)
downloadpoky-eb4854f903e31706d2d395d05521424bfa303c0d.tar.gz
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 <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/cooker.py67
1 files changed, 27 insertions, 40 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:
345 if pkgs_to_build[0] in set(ignore.split()): 345 if pkgs_to_build[0] in set(ignore.split()):
346 bb.fatal("%s is in ASSUME_PROVIDED" % pkgs_to_build[0]) 346 bb.fatal("%s is in ASSUME_PROVIDED" % pkgs_to_build[0])
347 347
348 localdata = data.createCopy(self.data) 348 taskdata, runlist, pkgs_to_build = self.buildTaskData(pkgs_to_build, None, self.configuration.abort)
349 bb.data.update_data(localdata)
350 bb.data.expandKeys(localdata)
351
352 taskdata = bb.taskdata.TaskData(self.configuration.abort)
353 taskdata.add_provider(localdata, self.recipecache, pkgs_to_build[0])
354 taskdata.add_unresolved(localdata, self.recipecache)
355 349
356 targetid = taskdata.getbuild_id(pkgs_to_build[0]) 350 targetid = taskdata.getbuild_id(pkgs_to_build[0])
357 fnid = taskdata.build_targets[targetid][0] 351 fnid = taskdata.build_targets[targetid][0]
@@ -383,34 +377,44 @@ class BBCooker:
383 if data.getVarFlag( e, 'python', envdata ): 377 if data.getVarFlag( e, 'python', envdata ):
384 logger.plain("\npython %s () {\n%s}\n", e, data.getVar(e, envdata, 1)) 378 logger.plain("\npython %s () {\n%s}\n", e, data.getVar(e, envdata, 1))
385 379
386 def prepareTreeData(self, pkgs_to_build, task): 380
381 def buildTaskData(self, pkgs_to_build, task, abort):
387 """ 382 """
388 Prepare a runqueue and taskdata object for iteration over pkgs_to_build 383 Prepare a runqueue and taskdata object for iteration over pkgs_to_build
389 """ 384 """
390 bb.event.fire(bb.event.TreeDataPreparationStarted(), self.data) 385 bb.event.fire(bb.event.TreeDataPreparationStarted(), self.data)
391 386
392 # If we are told to do the None task then query the default task 387 # A task of None means use the default task
393 if (task == None): 388 if task is None:
394 task = self.configuration.cmd 389 task = self.configuration.cmd
395 390
396 pkgs_to_build = self.checkPackages(pkgs_to_build) 391 fulltargetlist = self.checkPackages(pkgs_to_build)
397 392
398 localdata = data.createCopy(self.data) 393 localdata = data.createCopy(self.data)
399 bb.data.update_data(localdata) 394 bb.data.update_data(localdata)
400 bb.data.expandKeys(localdata) 395 bb.data.expandKeys(localdata)
401 # We set abort to False here to prevent unbuildable targets raising 396 taskdata = bb.taskdata.TaskData(abort, skiplist=self.skiplist)
402 # an exception when we're just generating data
403 taskdata = bb.taskdata.TaskData(False, skiplist=self.skiplist)
404 397
405 runlist = []
406 current = 0 398 current = 0
407 for k in pkgs_to_build: 399 runlist = []
400 for k in fulltargetlist:
408 taskdata.add_provider(localdata, self.recipecache, k) 401 taskdata.add_provider(localdata, self.recipecache, k)
409 runlist.append([k, "do_%s" % task])
410 current += 1 402 current += 1
411 bb.event.fire(bb.event.TreeDataPreparationProgress(current, len(pkgs_to_build)), self.data) 403 runlist.append([k, "do_%s" % task])
404 bb.event.fire(bb.event.TreeDataPreparationProgress(current, len(fulltargetlist)), self.data)
412 taskdata.add_unresolved(localdata, self.recipecache) 405 taskdata.add_unresolved(localdata, self.recipecache)
413 bb.event.fire(bb.event.TreeDataPreparationCompleted(len(pkgs_to_build)), self.data) 406 bb.event.fire(bb.event.TreeDataPreparationCompleted(len(fulltargetlist)), self.data)
407 return taskdata, runlist, fulltargetlist
408
409 def prepareTreeData(self, pkgs_to_build, task):
410 """
411 Prepare a runqueue and taskdata object for iteration over pkgs_to_build
412 """
413
414 # We set abort to False here to prevent unbuildable targets raising
415 # an exception when we're just generating data
416 taskdata, runlist, pkgs_to_build = self.buildTaskData(pkgs_to_build, task, False)
417
414 return runlist, taskdata 418 return runlist, taskdata
415 419
416 ######## WARNING : this function requires cache_extra to be enabled ######## 420 ######## WARNING : this function requires cache_extra to be enabled ########
@@ -1073,13 +1077,6 @@ class BBCooker:
1073 Attempt to build the targets specified 1077 Attempt to build the targets specified
1074 """ 1078 """
1075 1079
1076 # If we are told to do the NULL task then query the default task
1077 if (task == None):
1078 task = self.configuration.cmd
1079
1080 universe = ('universe' in targets)
1081 targets = self.checkPackages(targets)
1082
1083 def buildTargetsIdle(server, rq, abort): 1080 def buildTargetsIdle(server, rq, abort):
1084 if abort or self.state == state.forceshutdown: 1081 if abort or self.state == state.forceshutdown:
1085 rq.finish_runqueue(True) 1082 rq.finish_runqueue(True)
@@ -1105,23 +1102,13 @@ class BBCooker:
1105 1102
1106 self.buildSetVars() 1103 self.buildSetVars()
1107 1104
1108 buildname = self.data.getVar("BUILDNAME") 1105 taskdata, runlist, fulltargetlist = self.buildTaskData(targets, task, self.configuration.abort)
1109 bb.event.fire(bb.event.BuildStarted(buildname, targets), self.data)
1110 1106
1111 localdata = data.createCopy(self.data) 1107 buildname = self.data.getVar("BUILDNAME")
1112 bb.data.update_data(localdata) 1108 bb.event.fire(bb.event.BuildStarted(buildname, fulltargetlist), self.data)
1113 bb.data.expandKeys(localdata)
1114
1115 taskdata = bb.taskdata.TaskData(self.configuration.abort, skiplist=self.skiplist)
1116
1117 runlist = []
1118 for k in targets:
1119 taskdata.add_provider(localdata, self.recipecache, k)
1120 runlist.append([k, "do_%s" % task])
1121 taskdata.add_unresolved(localdata, self.recipecache)
1122 1109
1123 rq = bb.runqueue.RunQueue(self, self.data, self.recipecache, taskdata, runlist) 1110 rq = bb.runqueue.RunQueue(self, self.data, self.recipecache, taskdata, runlist)
1124 if universe: 1111 if 'universe' in targets:
1125 rq.rqdata.warn_multi_bb = True 1112 rq.rqdata.warn_multi_bb = True
1126 1113
1127 self.configuration.server_register_idlecallback(buildTargetsIdle, rq) 1114 self.configuration.server_register_idlecallback(buildTargetsIdle, rq)