]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bitbake/cooker: add generateTargetsTree method
authorJoshua Lock <josh@linux.intel.com>
Fri, 7 Jan 2011 11:45:00 +0000 (11:45 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 3 Mar 2011 22:30:21 +0000 (22:30 +0000)
The generateTargetsTree() command needs to return a model which includes more
metadata than the one generated by generateDepTree().

This patch adds a new method generateTargetsTreeData() to the cooker, based
on generateDepData(), and switches generateTargetsTree() to use it.

(From Poky rev: dcfc5ae7b1f5925587b0675e1cba6c60f098267c)

Signed-off-by: Joshua Lock <josh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/cooker.py

index 46d059db39aaf789501a1881f38dabb848b51f83..98f7ed280211f6963ac1ebda0df8ca0c15938058 100644 (file)
@@ -453,7 +453,10 @@ class BBCooker:
 
         bb.event.fire(bb.event.ConfigFilesFound(var, possible), self.configuration.data)
 
-    def checkInheritsClass(self, klass):
+    def findInheritsClass(self, klass):
+        """
+        Find all recipes which inherit the specified class
+        """
         pkg_list = []
 
         for pfn in self.status.pkg_fn:
@@ -463,6 +466,64 @@ class BBCooker:
 
         return pkg_list
 
+    def generateTargetsTreeData(self, pkgs_to_build, task):
+        """
+        Create a tree of pkgs_to_build metadata, returning the data.
+        """
+
+        # Need files parsed
+        self.updateCache()
+
+        # If we are told to do the None task then query the default task
+        if (task == None):
+            task = self.configuration.cmd
+
+        pkgs_to_build = self.checkPackages(pkgs_to_build)
+
+        localdata = data.createCopy(self.configuration.data)
+        bb.data.update_data(localdata)
+        bb.data.expandKeys(localdata)
+        taskdata = bb.taskdata.TaskData(self.configuration.abort)
+
+        runlist = []
+        for k in pkgs_to_build:
+            taskdata.add_provider(localdata, self.status, k)
+            runlist.append([k, "do_%s" % task])
+        taskdata.add_unresolved(localdata, self.status)
+
+        rq = bb.runqueue.RunQueue(self, self.configuration.data, self.status, taskdata, runlist)
+        rq.rqdata.prepare()
+
+        seen_fnids = []
+        target_tree = {}
+        target_tree["depends"] = {}
+        target_tree["pn"] = {}
+        target_tree["rdepends-pn"] = {}
+
+        for task in xrange(len(rq.rqdata.runq_fnid)):
+            taskname = rq.rqdata.runq_task[task]
+            fnid = rq.rqdata.runq_fnid[task]
+            fn = taskdata.fn_index[fnid]
+            pn = self.status.pkg_fn[fn]
+            version  = "%s:%s-%s" % self.status.pkg_pepvpr[fn]
+            if pn not in target_tree["pn"]:
+                target_tree["pn"][pn] = {}
+                target_tree["pn"][pn]["filename"] = fn
+                target_tree["pn"][pn]["version"] = version
+            if fnid not in seen_fnids:
+                seen_fnids.append(fnid)
+                packages = []
+
+                target_tree["depends"][pn] = []
+                for dep in taskdata.depids[fnid]:
+                    target_tree["depends"][pn].append(taskdata.build_names_index[dep])
+
+                target_tree["rdepends-pn"][pn] = []
+                for rdep in taskdata.rdepids[fnid]:
+                    target_tree["rdepends-pn"][pn].append(taskdata.run_names_index[rdep])
+
+        return target_tree
+
     def generateTargetsTree(self, klass):
         """
         Generate a dependency tree of buildable targets
@@ -472,11 +533,11 @@ class BBCooker:
         # if inherited_class passed ensure all recipes which inherit the
         # specified class are included in pkgs
         if klass:
-            extra_pkgs = self.checkInheritsClass(klass)
+            extra_pkgs = self.findInheritsClass(klass)
             pkgs = pkgs + extra_pkgs
 
         # generate a dependency tree for all our packages
-        tree = self.generateDepTreeData(pkgs, 'build')
+        tree = self.generateTargetsTreeData(pkgs, 'build')
         bb.event.fire(bb.event.TargetsTreeGenerated(tree), self.configuration.data)
 
     def buildWorldTargetList(self):