summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cooker.py
diff options
context:
space:
mode:
authorJoshua Lock <josh@linux.intel.com>2011-06-30 23:02:55 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-07-01 17:17:36 +0100
commit97e0beb393b9c3f2eeedc409bfc4924357d1c47e (patch)
tree28c54e2952e1b31f1e4fe6e2bfe5db31d4289b2d /bitbake/lib/bb/cooker.py
parent6c36f4a6aa76dbbca4f8c0623955058db34bd1e5 (diff)
downloadpoky-97e0beb393b9c3f2eeedc409bfc4924357d1c47e.tar.gz
cooker: remove code duplication in non trivial functions
The generateTargetsTreeData() and generateDepTreeData() functions perform are essentially the same function only creating slightly different data structures. Instead of duplicating non-trivial code drop generateTargetsTreeData and instead have an optional boolean argument which defaults to False for generateDepTreeData() which has it include the extra fields required for the targets tree. (Bitbake rev: 3e38ea4e5748473740821b6e10c8477c08ab45e2) Signed-off-by: Joshua Lock <josh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/cooker.py')
-rw-r--r--bitbake/lib/bb/cooker.py56
1 files changed, 12 insertions, 44 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 9874f664b5..1b31cea880 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -327,9 +327,11 @@ class BBCooker:
327 327
328 return taskdata, rq 328 return taskdata, rq
329 329
330 def generateDepTreeData(self, pkgs_to_build, task): 330 def generateDepTreeData(self, pkgs_to_build, task, more_meta=False):
331 """ 331 """
332 Create a dependency tree of pkgs_to_build, returning the data. 332 Create a dependency tree of pkgs_to_build, returning the data.
333 When more_meta is set to True include summary, license and group
334 information in the returned tree.
333 """ 335 """
334 taskdata, rq = self.prepareTreeData(pkgs_to_build, task) 336 taskdata, rq = self.prepareTreeData(pkgs_to_build, task)
335 337
@@ -349,10 +351,18 @@ class BBCooker:
349 fn = taskdata.fn_index[fnid] 351 fn = taskdata.fn_index[fnid]
350 pn = self.status.pkg_fn[fn] 352 pn = self.status.pkg_fn[fn]
351 version = "%s:%s-%s" % self.status.pkg_pepvpr[fn] 353 version = "%s:%s-%s" % self.status.pkg_pepvpr[fn]
354 if more_meta:
355 summary = self.status.summary[fn]
356 lic = self.status.license[fn]
357 section = self.status.section[fn]
352 if pn not in depend_tree["pn"]: 358 if pn not in depend_tree["pn"]:
353 depend_tree["pn"][pn] = {} 359 depend_tree["pn"][pn] = {}
354 depend_tree["pn"][pn]["filename"] = fn 360 depend_tree["pn"][pn]["filename"] = fn
355 depend_tree["pn"][pn]["version"] = version 361 depend_tree["pn"][pn]["version"] = version
362 if more_meta:
363 depend_tree["pn"][pn]["summary"] = summary
364 depend_tree["pn"][pn]["license"] = lic
365 depend_tree["pn"][pn]["section"] = section
356 for dep in rq.rqdata.runq_depends[task]: 366 for dep in rq.rqdata.runq_depends[task]:
357 depfn = taskdata.fn_index[rq.rqdata.runq_fnid[dep]] 367 depfn = taskdata.fn_index[rq.rqdata.runq_fnid[dep]]
358 deppn = self.status.pkg_fn[depfn] 368 deppn = self.status.pkg_fn[depfn]
@@ -579,48 +589,6 @@ class BBCooker:
579 589
580 return pkg_list 590 return pkg_list
581 591
582 def generateTargetsTreeData(self, pkgs_to_build, task):
583 """
584 Create a tree of pkgs_to_build metadata, returning the data.
585 """
586 taskdata, rq = self.prepareTreeData(pkgs_to_build, task)
587
588 seen_fnids = []
589 target_tree = {}
590 target_tree["depends"] = {}
591 target_tree["pn"] = {}
592 target_tree["rdepends-pn"] = {}
593
594 for task in xrange(len(rq.rqdata.runq_fnid)):
595 taskname = rq.rqdata.runq_task[task]
596 fnid = rq.rqdata.runq_fnid[task]
597 fn = taskdata.fn_index[fnid]
598 pn = self.status.pkg_fn[fn]
599 version = "%s:%s-%s" % self.status.pkg_pepvpr[fn]
600 summary = self.status.summary[fn]
601 license = self.status.license[fn]
602 section = self.status.section[fn]
603 if pn not in target_tree["pn"]:
604 target_tree["pn"][pn] = {}
605 target_tree["pn"][pn]["filename"] = fn
606 target_tree["pn"][pn]["version"] = version
607 target_tree["pn"][pn]["summary"] = summary
608 target_tree["pn"][pn]["license"] = license
609 target_tree["pn"][pn]["section"] = section
610 if fnid not in seen_fnids:
611 seen_fnids.append(fnid)
612 packages = []
613
614 target_tree["depends"][pn] = []
615 for dep in taskdata.depids[fnid]:
616 target_tree["depends"][pn].append(taskdata.build_names_index[dep])
617
618 target_tree["rdepends-pn"][pn] = []
619 for rdep in taskdata.rdepids[fnid]:
620 target_tree["rdepends-pn"][pn].append(taskdata.run_names_index[rdep])
621
622 return target_tree
623
624 def generateTargetsTree(self, klass=None, pkgs=[]): 592 def generateTargetsTree(self, klass=None, pkgs=[]):
625 """ 593 """
626 Generate a dependency tree of buildable targets 594 Generate a dependency tree of buildable targets
@@ -636,7 +604,7 @@ class BBCooker:
636 pkgs = pkgs + extra_pkgs 604 pkgs = pkgs + extra_pkgs
637 605
638 # generate a dependency tree for all our packages 606 # generate a dependency tree for all our packages
639 tree = self.generateTargetsTreeData(pkgs, 'build') 607 tree = self.generateDepTreeData(pkgs, 'build', more_meta=True)
640 bb.event.fire(bb.event.TargetsTreeGenerated(tree), self.configuration.data) 608 bb.event.fire(bb.event.TargetsTreeGenerated(tree), self.configuration.data)
641 609
642 def buildWorldTargetList(self): 610 def buildWorldTargetList(self):