[Toaster] [PATCH v6 39/41] toasterui: detect build run start correctly on Jethro

Ed Bartosh ed.bartosh at linux.intel.com
Wed Mar 23 01:15:30 PDT 2016


From: Elliot Smith <elliot.smith at intel.com>

We currently use the TargetsAcquired event fired by the XMLRPC
server to mark the start of a build run from the command line.
At this point, we create the Build object in buildinfohelper,
then append targets etc. to it as the run continues.

However, on Jethro, this event isn't fired. This means that we
can't support builds with the Jethro release correctly, as
a Build object is never created.

Add a condition so that we can create a Build object when building
with Jethro by falling back to the BuildStarted event. Jethro
builds which fail early (bad target, bad MACHINE, bad DISTRO etc.)
will not be captured (as we need the TargetsAcquired event for
that), but other builds which succeed or fail later will be
captured.

Signed-off-by: Elliot Smith <elliot.smith at intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>
---
 bitbake/lib/bb/ui/buildinfohelper.py |  9 +++------
 bitbake/lib/bb/ui/toasterui.py       | 26 +++++++++++++++++++-------
 2 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py
index 406f608..328020f 100644
--- a/bitbake/lib/bb/ui/buildinfohelper.py
+++ b/bitbake/lib/bb/ui/buildinfohelper.py
@@ -979,18 +979,15 @@ class BuildInfoHelper(object):
         build_information = self._get_build_information(build_log_path)
         self.internal_state['build'] = self.orm_wrapper.create_build_object(build_information, self.brbe)
 
-    def store_targets(self, event):
+    def store_targets(self, targets):
         """
         store targets for the current build, if that build was started from
         the command line; targets for non-cli builds are irrelevant, as we
         create them from the BuildRequest anyway
 
-        event: a TargetsAcquired event with a task property (e.g. "build")
-        and a targetsList property (e.g. ["zlib", "dropbear"])
+        targets: a list of targets for the build, e.g.
+        ["zlib:build", "dropbear:build"]
         """
-        targets = map(lambda target: target + ':' + event.task,
-                      event.targetsList)
-
         target_information = {
             'targets': targets,
             'build': self.internal_state['build']
diff --git a/bitbake/lib/bb/ui/toasterui.py b/bitbake/lib/bb/ui/toasterui.py
index 8467978..c4fce63 100644
--- a/bitbake/lib/bb/ui/toasterui.py
+++ b/bitbake/lib/bb/ui/toasterui.py
@@ -232,18 +232,30 @@ def main(server, eventHandler, params):
             # pylint: disable=protected-access
             # the code will look into the protected variables of the event; no easy way around this
 
-            # start of build: this event is fired just before the buildTargets()
-            # command is invoked on the XMLRPC server
-            if isinstance(event, bb.event.TargetsAcquired):
+            # start of build: TargetsAcquired event is fired just before the
+            # buildTargets() command is invoked on the XMLRPC server; if
+            # we are on Jethro, we don't get TargetsAcquired, so treat
+            # BuildStarted as the start of the build instead
+            targets_acquired = isinstance(event, bb.event.TargetsAcquired)
+            build_started = isinstance(event, bb.event.BuildStarted)
+
+            if targets_acquired or build_started:
                 if not (build_log and build_log_file_path):
                     build_log, build_log_file_path = _open_build_log(log_dir)
-                buildinfohelper.store_new_build(build_log_file_path)
-                buildinfohelper.store_targets(event)
-                continue
+                    buildinfohelper.store_new_build(build_log_file_path)
+
+                    # BuildStarted signals the start of the build on Toaster 2.0,
+                    # TargetsAcquired signals it on Toaster 2.1+
+                    if build_started:
+                        targets = event._pkgs
+                    else:
+                        targets = map(lambda target: target + ':' + event.task, event.targetsList)
+
+                    buildinfohelper.store_targets(targets)
 
             # when the build proper starts, we extract information about
             # any layers and config data
-            if isinstance(event, bb.event.BuildStarted):
+            if build_started:
                 buildinfohelper.update_build(event)
                 continue
 
-- 
2.1.4



More information about the toaster mailing list