[gnome-builder/wip/chergert/pipeline: 43/48] build-tools: port to IdeBuildPipeline



commit de0ba741509956efec2768ddada76f0696774e5d
Author: Christian Hergert <chergert redhat com>
Date:   Fri Feb 3 13:57:40 2017 -0800

    build-tools: port to IdeBuildPipeline
    
    This updates the build tools plugin to use the build pipeline to track
    build progress and logging.

 plugins/build-tools/gbp-build-log-panel.c       |   85 +++++---
 plugins/build-tools/gbp-build-log-panel.h       |    5 +-
 plugins/build-tools/gbp-build-panel.c           |  258 ++++++++++++-----------
 plugins/build-tools/gbp-build-panel.h           |    3 -
 plugins/build-tools/gbp-build-tool.c            |   98 ++++------
 plugins/build-tools/gbp-build-workbench-addin.c |   36 ++--
 6 files changed, 251 insertions(+), 234 deletions(-)
---
diff --git a/plugins/build-tools/gbp-build-log-panel.c b/plugins/build-tools/gbp-build-log-panel.c
index 59d02e0..7de582a 100644
--- a/plugins/build-tools/gbp-build-log-panel.c
+++ b/plugins/build-tools/gbp-build-log-panel.c
@@ -29,8 +29,7 @@ struct _GbpBuildLogPanel
 {
   PnlDockWidget      parent_instance;
 
-  IdeBuildResult    *result;
-  EggSignalGroup    *signals;
+  IdeBuildPipeline  *pipeline;
   GtkCssProvider    *css;
   GSettings         *settings;
   GtkTextBuffer     *buffer;
@@ -38,11 +37,13 @@ struct _GbpBuildLogPanel
   GtkScrolledWindow *scroller;
   GtkTextView       *text_view;
   GtkTextTag        *stderr_tag;
+
+  guint              log_observer;
 };
 
 enum {
   PROP_0,
-  PROP_RESULT,
+  PROP_PIPELINE,
   LAST_PROP
 };
 
@@ -87,23 +88,26 @@ gbp_build_log_panel_reset_view (GbpBuildLogPanel *self)
 }
 
 static void
-gbp_build_log_panel_log (GbpBuildLogPanel  *self,
-                         IdeBuildResultLog  log,
-                         const gchar       *message,
-                         IdeBuildResult    *result)
+gbp_build_log_panel_log_observer (IdeBuildLogStream  stream,
+                                  const gchar       *message,
+                                  gssize             message_len,
+                                  gpointer           user_data)
 {
+  GbpBuildLogPanel *self = user_data;
   GtkTextMark *insert;
   GtkTextIter iter;
 
   g_assert (GBP_IS_BUILD_LOG_PANEL (self));
   g_assert (message != NULL);
-  g_assert (IDE_IS_BUILD_RESULT (result));
+  g_assert (message_len >= 0);
+  g_assert (message[message_len] == '\0');
 
   gtk_text_buffer_get_end_iter (self->buffer, &iter);
 
-  if (G_LIKELY (log == IDE_BUILD_RESULT_LOG_STDOUT))
+  if G_LIKELY (stream == IDE_BUILD_LOG_STDOUT)
     {
       gtk_text_buffer_insert (self->buffer, &iter, message, -1);
+      gtk_text_buffer_insert (self->buffer, &iter, "\n", 1);
     }
   else
     {
@@ -112,6 +116,7 @@ gbp_build_log_panel_log (GbpBuildLogPanel  *self,
 
       offset = gtk_text_iter_get_offset (&iter);
       gtk_text_buffer_insert (self->buffer, &iter, message, -1);
+      gtk_text_buffer_insert (self->buffer, &iter, "\n", 1);
       gtk_text_buffer_get_iter_at_offset (self->buffer, &begin, offset);
       gtk_text_buffer_apply_tag (self->buffer, self->stderr_tag, &begin, &iter);
     }
@@ -121,16 +126,30 @@ gbp_build_log_panel_log (GbpBuildLogPanel  *self,
 }
 
 void
-gbp_build_log_panel_set_result (GbpBuildLogPanel *self,
-                                IdeBuildResult   *result)
+gbp_build_log_panel_set_pipeline (GbpBuildLogPanel *self,
+                                  IdeBuildPipeline *pipeline)
 {
   g_return_if_fail (GBP_IS_BUILD_LOG_PANEL (self));
-  g_return_if_fail (!result || IDE_IS_BUILD_RESULT (result));
+  g_return_if_fail (!pipeline || IDE_IS_BUILD_PIPELINE (pipeline));
 
-  if (g_set_object (&self->result, result))
+  if (pipeline != self->pipeline)
     {
-      gbp_build_log_panel_reset_view (self);
-      egg_signal_group_set_target (self->signals, result);
+      if (self->pipeline != NULL)
+        {
+          ide_build_pipeline_remove_log_observer (self->pipeline, self->log_observer);
+          self->log_observer = 0;
+          g_clear_object (&self->pipeline);
+        }
+
+      if (pipeline != NULL)
+        {
+          self->pipeline = g_object_ref (pipeline);
+          self->log_observer =
+            ide_build_pipeline_add_log_observer (self->pipeline,
+                                                 gbp_build_log_panel_log_observer,
+                                                 self,
+                                                 NULL);
+        }
     }
 }
 
@@ -174,8 +193,7 @@ gbp_build_log_panel_finalize (GObject *object)
 
   self->stderr_tag = NULL;
 
-  g_clear_object (&self->result);
-  g_clear_object (&self->signals);
+  g_clear_object (&self->pipeline);
   g_clear_object (&self->css);
   g_clear_object (&self->settings);
 
@@ -183,6 +201,16 @@ gbp_build_log_panel_finalize (GObject *object)
 }
 
 static void
+gbp_build_log_panel_dispose (GObject *object)
+{
+  GbpBuildLogPanel *self = (GbpBuildLogPanel *)object;
+
+  gbp_build_log_panel_set_pipeline (self, NULL);
+
+  G_OBJECT_CLASS (gbp_build_log_panel_parent_class)->dispose (object);
+}
+
+static void
 gbp_build_log_panel_get_property (GObject    *object,
                                   guint       prop_id,
                                   GValue     *value,
@@ -192,8 +220,8 @@ gbp_build_log_panel_get_property (GObject    *object,
 
   switch (prop_id)
     {
-    case PROP_RESULT:
-      g_value_set_object (value, self->result);
+    case PROP_PIPELINE:
+      g_value_set_object (value, self->pipeline);
       break;
 
     default:
@@ -211,8 +239,8 @@ gbp_build_log_panel_set_property (GObject      *object,
 
   switch (prop_id)
     {
-    case PROP_RESULT:
-      gbp_build_log_panel_set_result (self, g_value_get_object (value));
+    case PROP_PIPELINE:
+      gbp_build_log_panel_set_pipeline (self, g_value_get_object (value));
       break;
 
     default:
@@ -226,6 +254,7 @@ gbp_build_log_panel_class_init (GbpBuildLogPanelClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
+  object_class->dispose = gbp_build_log_panel_dispose;
   object_class->finalize = gbp_build_log_panel_finalize;
   object_class->get_property = gbp_build_log_panel_get_property;
   object_class->set_property = gbp_build_log_panel_set_property;
@@ -234,11 +263,11 @@ gbp_build_log_panel_class_init (GbpBuildLogPanelClass *klass)
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/builder/plugins/build-tools-plugin/gbp-build-log-panel.ui");
   gtk_widget_class_bind_template_child (widget_class, GbpBuildLogPanel, scroller);
 
-  properties [PROP_RESULT] =
-    g_param_spec_object ("result",
+  properties [PROP_PIPELINE] =
+    g_param_spec_object ("pipeline",
                          "Result",
                          "Result",
-                         IDE_TYPE_BUILD_RESULT,
+                         IDE_TYPE_BUILD_PIPELINE,
                          (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
   g_object_class_install_properties (object_class, LAST_PROP, properties);
@@ -255,14 +284,6 @@ gbp_build_log_panel_init (GbpBuildLogPanel *self)
 
   gbp_build_log_panel_reset_view (self);
 
-  self->signals = egg_signal_group_new (IDE_TYPE_BUILD_RESULT);
-
-  egg_signal_group_connect_object (self->signals,
-                                   "log",
-                                   G_CALLBACK (gbp_build_log_panel_log),
-                                   self,
-                                   G_CONNECT_SWAPPED);
-
   self->settings = g_settings_new ("org.gnome.builder.terminal");
   g_signal_connect_object (self->settings,
                            "changed::font-name",
diff --git a/plugins/build-tools/gbp-build-log-panel.h b/plugins/build-tools/gbp-build-log-panel.h
index df407ba..f4d5079 100644
--- a/plugins/build-tools/gbp-build-log-panel.h
+++ b/plugins/build-tools/gbp-build-log-panel.h
@@ -19,7 +19,6 @@
 #ifndef GBP_BUILD_LOG_PANEL_H
 #define GBP_BUILD_LOG_PANEL_H
 
-#include <gtk/gtk.h>
 #include <ide.h>
 
 G_BEGIN_DECLS
@@ -28,8 +27,8 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (GbpBuildLogPanel, gbp_build_log_panel, GBP, BUILD_LOG_PANEL, PnlDockWidget)
 
-void gbp_build_log_panel_set_result (GbpBuildLogPanel *self,
-                                     IdeBuildResult   *result);
+void gbp_build_log_panel_set_pipeline (GbpBuildLogPanel *self,
+                                       IdeBuildPipeline *pipeline);
 
 G_END_DECLS
 
diff --git a/plugins/build-tools/gbp-build-panel.c b/plugins/build-tools/gbp-build-panel.c
index d875ef9..0fb954f 100644
--- a/plugins/build-tools/gbp-build-panel.c
+++ b/plugins/build-tools/gbp-build-panel.c
@@ -19,19 +19,14 @@
 #include <glib/gi18n.h>
 #include <ide.h>
 
-#include "egg-binding-group.h"
-#include "egg-signal-group.h"
-
 #include "gbp-build-panel.h"
 
 struct _GbpBuildPanel
 {
   PnlDockWidget        parent_instance;
 
-  IdeBuildResult      *result;
-  EggSignalGroup      *signals;
-  EggBindingGroup     *bindings;
   GHashTable          *diags_hash;
+  IdeBuildPipeline    *pipeline;
 
   GtkListStore        *diagnostics_store;
   GtkCellRendererText *diagnostics_text;
@@ -51,23 +46,23 @@ struct _GbpBuildPanel
 G_DEFINE_TYPE (GbpBuildPanel, gbp_build_panel, PNL_TYPE_DOCK_WIDGET)
 
 enum {
-  PROP_0,
-  PROP_RESULT,
-  LAST_PROP
-};
-
-enum {
   COLUMN_DIAGNOSTIC,
   COLUMN_TEXT,
   LAST_COLUMN
 };
 
-static GParamSpec *properties [LAST_PROP];
+enum {
+  PROP_0,
+  PROP_PIPELINE,
+  N_PROPS
+};
+
+static GParamSpec *properties [N_PROPS];
 
 static void
-gbp_build_panel_diagnostic (GbpBuildPanel  *self,
-                            IdeDiagnostic  *diagnostic,
-                            IdeBuildResult *result)
+gbp_build_panel_diagnostic (GbpBuildPanel    *self,
+                            IdeDiagnostic    *diagnostic,
+                            IdeBuildPipeline *pipeline)
 {
   IdeDiagnosticSeverity severity;
   guint hash;
@@ -76,7 +71,7 @@ gbp_build_panel_diagnostic (GbpBuildPanel  *self,
 
   g_assert (GBP_IS_BUILD_PANEL (self));
   g_assert (diagnostic != NULL);
-  g_assert (IDE_IS_BUILD_RESULT (result));
+  g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
 
   severity = ide_diagnostic_get_severity (diagnostic);
 
@@ -151,49 +146,73 @@ gbp_build_panel_diagnostic (GbpBuildPanel  *self,
 static void
 gbp_build_panel_update_running_time (GbpBuildPanel *self)
 {
+  g_autofree gchar *text = NULL;
+
   g_assert (GBP_IS_BUILD_PANEL (self));
 
-  if (self->result != NULL)
+  if (self->pipeline != NULL)
     {
+      IdeBuildManager *build_manager;
+      IdeContext *context;
       GTimeSpan span;
-      guint hours;
-      guint minutes;
-      guint seconds;
-      gchar *text;
-
-      span = ide_build_result_get_running_time (self->result);
 
-      hours = span / G_TIME_SPAN_HOUR;
-      minutes = (span % G_TIME_SPAN_HOUR) / G_TIME_SPAN_MINUTE;
-      seconds = (span % G_TIME_SPAN_MINUTE) / G_TIME_SPAN_SECOND;
+      context = ide_widget_get_context (GTK_WIDGET (self));
+      build_manager = ide_context_get_build_manager (context);
 
-      text = g_strdup_printf ("%02u:%02u:%02u", hours, minutes, seconds);
-      gtk_label_set_label (self->running_time_label, text);
-      g_free (text);
-    }
-  else
-    {
-      gtk_label_set_label (self->running_time_label, NULL);
+      span = ide_build_manager_get_running_time (build_manager);
+      text = ide_g_time_span_to_label (span);
     }
+
+  gtk_label_set_label (self->running_time_label, text);
 }
 
 static void
-gbp_build_panel_connect (GbpBuildPanel  *self,
-                         IdeBuildResult *result)
+gbp_build_panel_started (GbpBuildPanel    *self,
+                         IdeBuildPipeline *pipeline)
+{
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BUILD_PANEL (self));
+  g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
+
+  self->error_count = 0;
+  self->warning_count = 0;
+
+  gtk_label_set_label (self->warnings_label, "—");
+  gtk_label_set_label (self->errors_label, "—");
+
+  gtk_list_store_clear (self->diagnostics_store);
+  g_hash_table_remove_all (self->diags_hash);
+
+  IDE_EXIT;
+}
+
+static void
+gbp_build_panel_connect (GbpBuildPanel    *self,
+                         IdeBuildPipeline *pipeline)
 {
   g_return_if_fail (GBP_IS_BUILD_PANEL (self));
-  g_return_if_fail (IDE_IS_BUILD_RESULT (result));
-  g_return_if_fail (self->result == NULL);
+  g_return_if_fail (IDE_IS_BUILD_PIPELINE (pipeline));
+  g_return_if_fail (self->pipeline == NULL);
 
-  self->result = g_object_ref (result);
+  self->pipeline = g_object_ref (pipeline);
   self->error_count = 0;
   self->warning_count = 0;
 
   gtk_label_set_label (self->warnings_label, "—");
   gtk_label_set_label (self->errors_label, "—");
 
-  egg_signal_group_set_target (self->signals, result);
-  egg_binding_group_set_source (self->bindings, result);
+  g_signal_connect_object (pipeline,
+                           "diagnostic",
+                           G_CALLBACK (gbp_build_panel_diagnostic),
+                           self,
+                           G_CONNECT_SWAPPED);
+
+  g_signal_connect_object (pipeline,
+                           "started",
+                           G_CALLBACK (gbp_build_panel_started),
+                           self,
+                           G_CONNECT_SWAPPED);
 
   gtk_revealer_set_reveal_child (self->status_revealer, TRUE);
 
@@ -204,57 +223,38 @@ static void
 gbp_build_panel_disconnect (GbpBuildPanel *self)
 {
   g_return_if_fail (GBP_IS_BUILD_PANEL (self));
+  g_return_if_fail (IDE_IS_BUILD_PIPELINE (self->pipeline));
+
+  g_signal_handlers_disconnect_by_func (self->pipeline,
+                                        G_CALLBACK (gbp_build_panel_diagnostic),
+                                        self);
+  g_clear_object (&self->pipeline);
 
   gtk_revealer_set_reveal_child (self->status_revealer, FALSE);
 
-  egg_signal_group_set_target (self->signals, NULL);
-  egg_binding_group_set_source (self->bindings, NULL);
-  g_clear_object (&self->result);
   g_hash_table_remove_all (self->diags_hash);
   gtk_list_store_clear (self->diagnostics_store);
   gtk_stack_set_visible_child_name (self->stack, "empty-state");
 }
 
 void
-gbp_build_panel_set_result (GbpBuildPanel  *self,
-                            IdeBuildResult *result)
+gbp_build_panel_set_pipeline (GbpBuildPanel    *self,
+                              IdeBuildPipeline *pipeline)
 {
   g_return_if_fail (GBP_IS_BUILD_PANEL (self));
-  g_return_if_fail (!result || IDE_IS_BUILD_RESULT (result));
+  g_return_if_fail (!pipeline || IDE_IS_BUILD_PIPELINE (pipeline));
 
-  if (result != self->result)
+  if (pipeline != self->pipeline)
     {
-      if (self->result)
+      if (self->pipeline)
         gbp_build_panel_disconnect (self);
 
-      if (result)
-        gbp_build_panel_connect (self, result);
+      if (pipeline)
+        gbp_build_panel_connect (self, pipeline);
     }
 }
 
 static void
-gbp_build_panel_notify_running (GbpBuildPanel  *self,
-                                GParamSpec     *pspec,
-                                IdeBuildResult *result)
-{
-  g_assert (GBP_IS_BUILD_PANEL (self));
-  g_assert (IDE_IS_BUILD_RESULT (result));
-
-  gbp_build_panel_update_running_time (self);
-}
-
-static void
-gbp_build_panel_notify_running_time (GbpBuildPanel  *self,
-                                     GParamSpec     *pspec,
-                                     IdeBuildResult *result)
-{
-  g_assert (GBP_IS_BUILD_PANEL (self));
-  g_assert (IDE_IS_BUILD_RESULT (result));
-
-  gbp_build_panel_update_running_time (self);
-}
-
-static void
 gbp_build_panel_diagnostic_activated (GbpBuildPanel     *self,
                                       GtkTreePath       *path,
                                       GtkTreeViewColumn *colun,
@@ -371,15 +371,61 @@ gbp_build_panel_text_func (GtkCellLayout   *layout,
 }
 
 static void
+gbp_build_panel_context_handler (GtkWidget  *widget,
+                                 IdeContext *context)
+{
+  GbpBuildPanel *self = (GbpBuildPanel *)widget;
+  IdeBuildManager *build_manager;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BUILD_PANEL (self));
+  g_assert (!context || IDE_IS_CONTEXT (context));
+
+  if (context == NULL)
+    IDE_EXIT;
+
+  build_manager = ide_context_get_build_manager (context);
+
+  g_object_bind_property (build_manager, "message",
+                          self->status_label, "label",
+                          G_BINDING_SYNC_CREATE);
+
+  g_signal_connect_object (build_manager,
+                           "notify::running-time",
+                           G_CALLBACK (gbp_build_panel_update_running_time),
+                           self,
+                           G_CONNECT_SWAPPED);
+
+  g_signal_connect_object (build_manager,
+                           "build-started",
+                           G_CALLBACK (gbp_build_panel_update_running_time),
+                           self,
+                           G_CONNECT_SWAPPED);
+
+  g_signal_connect_object (build_manager,
+                           "build-finished",
+                           G_CALLBACK (gbp_build_panel_update_running_time),
+                           self,
+                           G_CONNECT_SWAPPED);
+
+  g_signal_connect_object (build_manager,
+                           "build-failed",
+                           G_CALLBACK (gbp_build_panel_update_running_time),
+                           self,
+                           G_CONNECT_SWAPPED);
+
+  IDE_EXIT;
+}
+
+static void
 gbp_build_panel_destroy (GtkWidget *widget)
 {
   GbpBuildPanel *self = (GbpBuildPanel *)widget;
 
-  if (self->result)
+  if (self->pipeline != NULL)
     gbp_build_panel_disconnect (self);
 
-  g_clear_object (&self->bindings);
-  g_clear_object (&self->signals);
   g_clear_pointer (&self->diags_hash, g_hash_table_unref);
 
   GTK_WIDGET_CLASS (gbp_build_panel_parent_class)->destroy (widget);
@@ -391,16 +437,16 @@ gbp_build_panel_get_property (GObject    *object,
                               GValue     *value,
                               GParamSpec *pspec)
 {
-  GbpBuildPanel *self = GBP_BUILD_PANEL(object);
+  GbpBuildPanel *self = GBP_BUILD_PANEL (object);
 
   switch (prop_id)
     {
-    case PROP_RESULT:
-      g_value_set_object (value, self->result);
+    case PROP_PIPELINE:
+      g_value_set_object (value, self->pipeline);
       break;
 
     default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
 }
 
@@ -410,16 +456,16 @@ gbp_build_panel_set_property (GObject      *object,
                               const GValue *value,
                               GParamSpec   *pspec)
 {
-  GbpBuildPanel *self = GBP_BUILD_PANEL(object);
+  GbpBuildPanel *self = GBP_BUILD_PANEL (object);
 
   switch (prop_id)
     {
-    case PROP_RESULT:
-      gbp_build_panel_set_result (self, g_value_get_object (value));
+    case PROP_PIPELINE:
+      gbp_build_panel_set_pipeline (self, g_value_get_object (value));
       break;
 
     default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
 }
 
@@ -429,19 +475,19 @@ gbp_build_panel_class_init (GbpBuildPanelClass *klass)
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
+  widget_class->destroy = gbp_build_panel_destroy;
+
   object_class->get_property = gbp_build_panel_get_property;
   object_class->set_property = gbp_build_panel_set_property;
 
-  widget_class->destroy = gbp_build_panel_destroy;
-
-  properties [PROP_RESULT] =
-    g_param_spec_object ("result",
-                         "Result",
-                         "Result",
-                         IDE_TYPE_BUILD_RESULT,
-                         (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  properties [PROP_PIPELINE] =
+    g_param_spec_object ("pipeline",
+                         NULL,
+                         NULL,
+                         IDE_TYPE_BUILD_PIPELINE,
+                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
-  g_object_class_install_properties (object_class, LAST_PROP, properties);
+  g_object_class_install_properties (object_class, N_PROPS, properties);
 
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/builder/plugins/build-tools-plugin/gbp-build-panel.ui");
   gtk_widget_class_set_css_name (widget_class, "buildpanel");
@@ -468,25 +514,7 @@ gbp_build_panel_init (GbpBuildPanel *self)
 
   g_object_set (self, "title", _("Build"), NULL);
 
-  self->signals = egg_signal_group_new (IDE_TYPE_BUILD_RESULT);
-
-  egg_signal_group_connect_object (self->signals,
-                                   "diagnostic",
-                                   G_CALLBACK (gbp_build_panel_diagnostic),
-                                   self,
-                                   G_CONNECT_SWAPPED);
-
-  egg_signal_group_connect_object (self->signals,
-                                   "notify::running",
-                                   G_CALLBACK (gbp_build_panel_notify_running),
-                                   self,
-                                   G_CONNECT_SWAPPED);
-
-  egg_signal_group_connect_object (self->signals,
-                                   "notify::running-time",
-                                   G_CALLBACK (gbp_build_panel_notify_running_time),
-                                   self,
-                                   G_CONNECT_SWAPPED);
+  ide_widget_set_context_handler (self, gbp_build_panel_context_handler);
 
   g_signal_connect_object (self->diagnostics_tree_view,
                            "row-activated",
@@ -498,10 +526,4 @@ gbp_build_panel_init (GbpBuildPanel *self)
                                       GTK_CELL_RENDERER (self->diagnostics_text),
                                       gbp_build_panel_text_func,
                                       self, NULL);
-
-
-  self->bindings = egg_binding_group_new ();
-
-  egg_binding_group_bind (self->bindings, "mode", self->status_label, "label",
-                          G_BINDING_SYNC_CREATE);
 }
diff --git a/plugins/build-tools/gbp-build-panel.h b/plugins/build-tools/gbp-build-panel.h
index 489b49c..a3e61ca 100644
--- a/plugins/build-tools/gbp-build-panel.h
+++ b/plugins/build-tools/gbp-build-panel.h
@@ -28,9 +28,6 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (GbpBuildPanel, gbp_build_panel, GBP, BUILD_PANEL, PnlDockWidget)
 
-void gbp_build_panel_set_result (GbpBuildPanel  *self,
-                                 IdeBuildResult *result);
-
 G_END_DECLS
 
 #endif /* GBP_BUILD_PANEL_H */
diff --git a/plugins/build-tools/gbp-build-tool.c b/plugins/build-tools/gbp-build-tool.c
index d63d396..231cf36 100644
--- a/plugins/build-tools/gbp-build-tool.c
+++ b/plugins/build-tools/gbp-build-tool.c
@@ -21,6 +21,7 @@
 #endif
 
 #include <glib/gi18n.h>
+#include <ide.h>
 
 #include "gbp-build-tool.h"
 
@@ -30,17 +31,15 @@ struct _GbpBuildTool
   gint64  build_start;
 };
 
-static gint                  parallel = -1;
-static IdeBuilderBuildFlags  flags;
-static gchar                *configuration_id;
-static gchar                *device_id;
-static gchar                *runtime_id;
+static gint   parallel = -1;
+static gchar *configuration_id;
+static gchar *device_id;
+static gchar *runtime_id;
 
 static void application_tool_init (IdeApplicationToolInterface *iface);
 
 G_DEFINE_TYPE_EXTENDED (GbpBuildTool, gbp_build_tool, G_TYPE_OBJECT, 0,
-                        G_IMPLEMENT_INTERFACE (IDE_TYPE_APPLICATION_TOOL,
-                                               application_tool_init))
+                        G_IMPLEMENT_INTERFACE (IDE_TYPE_APPLICATION_TOOL, application_tool_init))
 
 static void
 gbp_build_tool_class_init (GbpBuildToolClass *klass)
@@ -53,19 +52,19 @@ gbp_build_tool_init (GbpBuildTool *self)
 }
 
 static void
-gbp_build_tool_log (GbpBuildTool      *self,
-                    IdeBuildResultLog  log,
-                    const gchar       *message,
-                    IdeBuildResult    *build_result)
+gbp_build_tool_log_observer (IdeBuildLogStream  stream,
+                             const gchar       *message,
+                             gssize             message_len,
+                             gpointer           user_data)
 {
-  if (log == IDE_BUILD_RESULT_LOG_STDERR)
+  if (stream == IDE_BUILD_LOG_STDERR)
     g_printerr ("%s", message);
   else
     g_print ("%s", message);
 }
 
 static void
-print_build_info (IdeContext *context,
+print_build_info (IdeContext       *context,
                   IdeConfiguration *configuration)
 {
   IdeProject *project;
@@ -116,35 +115,35 @@ print_build_info (IdeContext *context,
 }
 
 static void
-gbp_build_tool_build_cb (GObject      *object,
-                         GAsyncResult *result,
-                         gpointer      user_data)
+gbp_build_tool_execute_cb (GObject      *object,
+                           GAsyncResult *result,
+                           gpointer      user_data)
 {
+  IdeBuildManager *build_manager = (IdeBuildManager *)object;
   g_autoptr(GTask) task = user_data;
-  g_autoptr(IdeBuildResult) build_result = NULL;
+  g_autoptr(GError) error = NULL;
   GbpBuildTool *self;
-  IdeBuilder *builder = (IdeBuilder *)object;
-  GError *error = NULL;
   guint64 completed_at;
   guint64 total_usec;
 
   g_assert (G_IS_TASK (task));
-  g_assert (IDE_IS_BUILDER (builder));
+  g_assert (IDE_IS_BUILD_MANAGER (build_manager));
 
   self = g_task_get_source_object (task);
   completed_at = g_get_monotonic_time ();
-  build_result = ide_builder_build_finish (builder, result, &error);
+
+  ide_build_manager_execute_finish (build_manager, result, &error);
 
   total_usec = completed_at - self->build_start;
 
-  if (build_result == NULL)
+  if (error != NULL)
     {
       g_printerr (_("===============\n"));
       g_printerr (_(" Build Failure: %s\n"), error->message);
       g_printerr (_(" Build ran for: %"G_GUINT64_FORMAT".%"G_GUINT64_FORMAT" seconds\n"),
                   (total_usec / 1000000), ((total_usec % 1000000) / 1000));
       g_printerr (_("===============\n"));
-      g_task_return_error (task, error);
+      g_task_return_error (task, g_steal_pointer (&error));
       return;
     }
 
@@ -170,17 +169,16 @@ gbp_build_tool_new_context_cb (GObject      *object,
 {
   g_autoptr(GTask) task = user_data;
   g_autoptr(IdeContext) context = NULL;
-  g_autoptr(IdeBuilder) builder = NULL;
-  g_autoptr(IdeBuildResult) build_result = NULL;
   g_autoptr(IdeConfiguration) configuration = NULL;
   IdeConfigurationManager *configuration_manager;
-  IdeBuildSystem *build_system;
-  GbpBuildTool *self;
+  IdeBuildManager *build_manager;
+  IdeBuildPipeline *pipeline;
+  GCancellable *cancellable;
   GError *error = NULL;
 
   g_assert (G_IS_TASK (task));
 
-  self = g_task_get_source_object (task);
+  cancellable = g_task_get_cancellable (task);
 
   context = ide_context_new_finish (result, &error);
 
@@ -233,37 +231,18 @@ gbp_build_tool_new_context_cb (GObject      *object,
 
   print_build_info (context, configuration);
 
-  build_system = ide_context_get_build_system (context);
-  builder = ide_build_system_get_builder (build_system, configuration, &error);
+  build_manager = ide_context_get_build_manager (context);
 
-  if (builder == NULL)
-    {
-      g_task_return_error (task, error);
-      return;
-    }
-
-  self->build_start = g_get_monotonic_time ();
+  pipeline = ide_build_manager_get_pipeline (build_manager);
+  ide_build_pipeline_add_log_observer (pipeline,
+                                       gbp_build_tool_log_observer,
+                                       NULL, NULL);
 
-  ide_builder_build_async (builder,
-                           flags,
-                           &build_result,
-                           g_task_get_cancellable (task),
-                           gbp_build_tool_build_cb,
-                           g_object_ref (task));
-
-  if (build_result != NULL)
-    {
-      /*
-       * XXX: Technically we could lose some log lines unless we
-       * guarantee that the build can't start until the main loop
-       * is reached. (Which is probably reasonable).
-       */
-      g_signal_connect_object (build_result,
-                               "log",
-                               G_CALLBACK (gbp_build_tool_log),
-                               g_task_get_source_object (task),
-                               G_CONNECT_SWAPPED);
-    }
+  ide_build_manager_execute_async (build_manager,
+                                   IDE_BUILD_PHASE_BUILD,
+                                   cancellable,
+                                   gbp_build_tool_execute_cb,
+                                   g_steal_pointer (&task));
 }
 
 static void
@@ -328,14 +307,13 @@ gbp_build_tool_run_async (IdeApplicationTool  *tool,
 
   if (clean)
     {
-      flags |= IDE_BUILDER_BUILD_FLAGS_FORCE_CLEAN;
-      flags |= IDE_BUILDER_BUILD_FLAGS_NO_BUILD;
+      /* TODO */
     }
 
   ide_context_new_async (project_file,
                          cancellable,
                          gbp_build_tool_new_context_cb,
-                         g_object_ref (task));
+                         g_steal_pointer (&task));
 }
 
 static gboolean
diff --git a/plugins/build-tools/gbp-build-workbench-addin.c b/plugins/build-tools/gbp-build-workbench-addin.c
index 8dae6b4..47f47ff 100644
--- a/plugins/build-tools/gbp-build-workbench-addin.c
+++ b/plugins/build-tools/gbp-build-workbench-addin.c
@@ -36,7 +36,7 @@ struct _GbpBuildWorkbenchAddin
   GbpBuildPerspective *build_perspective;
 
   /* Owned */
-  IdeBuildResult      *result;
+  IdeBuildPipeline    *pipeline;
   GSimpleActionGroup  *actions;
 };
 
@@ -47,25 +47,25 @@ G_DEFINE_TYPE_EXTENDED (GbpBuildWorkbenchAddin, gbp_build_workbench_addin, G_TYP
 
 enum {
   PROP_0,
-  PROP_RESULT,
+  PROP_PIPELINE,
   LAST_PROP
 };
 
 static GParamSpec *properties [LAST_PROP];
 
 static void
-gbp_build_workbench_addin_set_result (GbpBuildWorkbenchAddin *self,
-                                      IdeBuildResult         *result)
+gbp_build_workbench_addin_set_pipeline (GbpBuildWorkbenchAddin *self,
+                                        IdeBuildPipeline       *pipeline)
 {
   g_return_if_fail (GBP_IS_BUILD_WORKBENCH_ADDIN (self));
-  g_return_if_fail (!result || IDE_IS_BUILD_RESULT (result));
+  g_return_if_fail (!pipeline || IDE_IS_BUILD_PIPELINE (pipeline));
   g_return_if_fail (self->workbench != NULL);
 
-  if (g_set_object (&self->result, result))
+  if (g_set_object (&self->pipeline, pipeline))
     {
-      gbp_build_log_panel_set_result (self->build_log_panel, result);
+      gbp_build_log_panel_set_pipeline (self->build_log_panel, pipeline);
       gtk_widget_show (GTK_WIDGET (self->build_log_panel));
-      g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_RESULT]);
+      g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_PIPELINE]);
     }
 }
 
@@ -137,7 +137,7 @@ gbp_build_workbench_addin_load (IdeWorkbenchAddin *addin,
 
   g_signal_connect_object (build_manager,
                            "build-started",
-                           G_CALLBACK (gbp_build_workbench_addin_set_result),
+                           G_CALLBACK (gbp_build_workbench_addin_set_pipeline),
                            self,
                            G_CONNECT_SWAPPED);
 
@@ -158,7 +158,7 @@ gbp_build_workbench_addin_load (IdeWorkbenchAddin *addin,
   gtk_widget_insert_action_group (GTK_WIDGET (workbench), "build-tools",
                                   G_ACTION_GROUP (self->actions));
 
-  g_object_bind_property (self, "result", self->panel, "result", 0);
+  g_object_bind_property (self, "pipeline", self->panel, "pipeline", 0);
 
   self->build_perspective = g_object_new (GBP_TYPE_BUILD_PERSPECTIVE,
                                           "configuration-manager", configuration_manager,
@@ -194,8 +194,8 @@ gbp_build_workbench_addin_get_property (GObject    *object,
 
   switch (prop_id)
     {
-    case PROP_RESULT:
-      g_value_set_object (value, self->result);
+    case PROP_PIPELINE:
+      g_value_set_object (value, self->pipeline);
       break;
 
     default:
@@ -209,7 +209,7 @@ gbp_build_workbench_addin_finalize (GObject *object)
   GbpBuildWorkbenchAddin *self = (GbpBuildWorkbenchAddin *)object;
 
   g_clear_object (&self->actions);
-  g_clear_object (&self->result);
+  g_clear_object (&self->pipeline);
 
   G_OBJECT_CLASS (gbp_build_workbench_addin_parent_class)->finalize (object);
 }
@@ -222,11 +222,11 @@ gbp_build_workbench_addin_class_init (GbpBuildWorkbenchAddinClass *klass)
   object_class->finalize = gbp_build_workbench_addin_finalize;
   object_class->get_property = gbp_build_workbench_addin_get_property;
 
-  properties [PROP_RESULT] =
-    g_param_spec_object ("result",
-                         "Result",
-                         "The current build result",
-                         IDE_TYPE_BUILD_RESULT,
+  properties [PROP_PIPELINE] =
+    g_param_spec_object ("pipeline",
+                         "Pipeline",
+                         "The current build pipeline",
+                         IDE_TYPE_BUILD_PIPELINE,
                          (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
 
   g_object_class_install_properties (object_class, LAST_PROP, properties);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]