summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cooker.py
diff options
context:
space:
mode:
authorDongxiao Xu <dongxiao.xu@intel.com>2012-02-23 21:47:14 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-02-23 22:52:17 +0000
commitde77b9752ab2df56d87dc15ed5cd0d2cd5544dc7 (patch)
tree74b02b6df6ab08626eab2fd6b17440b6cfd977fa /bitbake/lib/bb/cooker.py
parent85fa989df7a4928e42aad2eb5f34a5f3c2c9ae93 (diff)
downloadpoky-de77b9752ab2df56d87dc15ed5cd0d2cd5544dc7.tar.gz
command.py: add resolve option for generateTargetsTree API
Currently we have generateTargetsTree API, which is used to get dependency information. However in that tree, there will be "virtual/xxx" in depends fields. Therefore we add the resolve option to replace it with its real providers. Besides, for packages that provided by multiple recipes, we will find their preverred provider. (Bitbake rev: 28501612efdfc6ee47576cc90deb6e897883e7f5) Signed-off-by: Dongxiao Xu <dongxiao.xu@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.py58
1 files changed, 47 insertions, 11 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index b0b58a6fdb..91fdc96b8a 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -429,7 +429,20 @@ class BBCooker:
429 429
430 return depend_tree 430 return depend_tree
431 431
432 def generatePkgDepTreeData(self, pkgs_to_build, task): 432 def append_package(self, taskdata, depend_tree_package, package):
433 if package not in depend_tree_package:
434 targetid = taskdata.getrun_id(package)
435 if targetid in taskdata.run_targets and taskdata.run_targets[targetid]:
436 fnid = taskdata.run_targets[targetid][0]
437 fn = taskdata.fn_index[fnid]
438 pn = self.status.pkg_fn[fn]
439 version = "%s:%s-%s" % self.status.pkg_pepvpr[fn]
440 depend_tree_package[package] = {}
441 depend_tree_package[package]["pn"] = pn
442 depend_tree_package[package]["filename"] = fn
443 depend_tree_package[package]["version"] = version
444
445 def generatePkgDepTreeData(self, pkgs_to_build, task, resolve=False):
433 """ 446 """
434 Create a dependency tree of pkgs_to_build, returning the data. 447 Create a dependency tree of pkgs_to_build, returning the data.
435 """ 448 """
@@ -446,6 +459,7 @@ class BBCooker:
446 depend_tree["rdepends-pn"] = {} 459 depend_tree["rdepends-pn"] = {}
447 depend_tree["packages"] = {} 460 depend_tree["packages"] = {}
448 depend_tree["rdepends-pkg"] = {} 461 depend_tree["rdepends-pkg"] = {}
462 depend_tree["rrecs-pkg"] = {}
449 463
450 for task in xrange(len(tasks_fnid)): 464 for task in xrange(len(tasks_fnid)):
451 fnid = tasks_fnid[task] 465 fnid = tasks_fnid[task]
@@ -456,6 +470,8 @@ class BBCooker:
456 lic = self.status.license[fn] 470 lic = self.status.license[fn]
457 section = self.status.section[fn] 471 section = self.status.section[fn]
458 description = self.status.description[fn] 472 description = self.status.description[fn]
473 rdepends = self.status.rundeps[fn]
474 rrecs = self.status.runrecs[fn]
459 if pn not in depend_tree["pn"]: 475 if pn not in depend_tree["pn"]:
460 depend_tree["pn"][pn] = {} 476 depend_tree["pn"][pn] = {}
461 depend_tree["pn"][pn]["filename"] = fn 477 depend_tree["pn"][pn]["filename"] = fn
@@ -464,6 +480,7 @@ class BBCooker:
464 depend_tree["pn"][pn]["license"] = lic 480 depend_tree["pn"][pn]["license"] = lic
465 depend_tree["pn"][pn]["section"] = section 481 depend_tree["pn"][pn]["section"] = section
466 depend_tree["pn"][pn]["description"] = description 482 depend_tree["pn"][pn]["description"] = description
483 depend_tree["pn"][pn]["packages"] = rdepends.keys()
467 484
468 if fnid not in seen_fnids: 485 if fnid not in seen_fnids:
469 seen_fnids.append(fnid) 486 seen_fnids.append(fnid)
@@ -471,25 +488,44 @@ class BBCooker:
471 488
472 depend_tree["depends"][pn] = [] 489 depend_tree["depends"][pn] = []
473 for dep in taskdata.depids[fnid]: 490 for dep in taskdata.depids[fnid]:
474 depend_tree["depends"][pn].append(taskdata.build_names_index[dep]) 491 if resolve:
492 item = taskdata.build_names_index[dep]
493 pn_provider = ""
494 targetid = taskdata.getbuild_id(item)
495 if targetid in taskdata.build_targets and taskdata.build_targets[targetid]:
496 fnid = taskdata.build_targets[targetid][0]
497 fn_provider = taskdata.fn_index[fnid]
498 pn_provider = self.status.pkg_fn[fn_provider]
499 else:
500 pn_provider = item
501 depend_tree["depends"][pn].append(pn_provider)
502 else:
503 depend_tree["depends"][pn].append(taskdata.build_names_index[dep])
475 504
476 depend_tree["rdepends-pn"][pn] = [] 505 depend_tree["rdepends-pn"][pn] = []
477 for rdep in taskdata.rdepids[fnid]: 506 for rdep in taskdata.rdepids[fnid]:
478 depend_tree["rdepends-pn"][pn].append(taskdata.run_names_index[rdep]) 507 depend_tree["rdepends-pn"][pn].append(taskdata.run_names_index[rdep])
479 508
480 rdepends = self.status.rundeps[fn]
481 for package in rdepends: 509 for package in rdepends:
482 depend_tree["rdepends-pkg"][package] = [] 510 depend_tree["rdepends-pkg"][package] = []
483 for rdepend in rdepends[package]: 511 for rdepend in rdepends[package]:
484 depend_tree["rdepends-pkg"][package].append(rdepend) 512 depend_tree["rdepends-pkg"][package].append(rdepend)
485 packages.append(package) 513 if resolve:
514 self.append_package(taskdata, depend_tree["packages"], rdepend)
515 if not package in packages:
516 packages.append(package)
517
518 for package in rrecs:
519 depend_tree["rrecs-pkg"][package] = []
520 for rrec in rrecs[package]:
521 depend_tree["rrecs-pkg"][package].append(rrec)
522 if resolve:
523 self.append_package(taskdata, depend_tree["packages"], rrec)
524 if not package in packages:
525 packages.append(package)
486 526
487 for package in packages: 527 for package in packages:
488 if package not in depend_tree["packages"]: 528 self.append_package(taskdata, depend_tree["packages"], package)
489 depend_tree["packages"][package] = {}
490 depend_tree["packages"][package]["pn"] = pn
491 depend_tree["packages"][package]["filename"] = fn
492 depend_tree["packages"][package]["version"] = version
493 529
494 return depend_tree 530 return depend_tree
495 531
@@ -735,7 +771,7 @@ class BBCooker:
735 771
736 return pkg_list 772 return pkg_list
737 773
738 def generateTargetsTree(self, klass=None, pkgs=[]): 774 def generateTargetsTree(self, klass=None, pkgs=[], resolve=False):
739 """ 775 """
740 Generate a dependency tree of buildable targets 776 Generate a dependency tree of buildable targets
741 Generate an event with the result 777 Generate an event with the result
@@ -750,7 +786,7 @@ class BBCooker:
750 pkgs = pkgs + extra_pkgs 786 pkgs = pkgs + extra_pkgs
751 787
752 # generate a dependency tree for all our packages 788 # generate a dependency tree for all our packages
753 tree = self.generatePkgDepTreeData(pkgs, 'build') 789 tree = self.generatePkgDepTreeData(pkgs, 'build', resolve)
754 bb.event.fire(bb.event.TargetsTreeGenerated(tree), self.configuration.data) 790 bb.event.fire(bb.event.TargetsTreeGenerated(tree), self.configuration.data)
755 791
756 def buildWorldTargetList(self): 792 def buildWorldTargetList(self):