[gnome-builder] autotools: execute runtime posthooks



commit 1c00cdd9e41a1854155189e407852f8f1ef34134
Author: Christian Hergert <chergert redhat com>
Date:   Tue Oct 11 17:25:49 2016 -0700

    autotools: execute runtime posthooks
    
    This adds a new function for executing the build that will
    also run the runtime posthooks. While the autotools code is
    starting to get a bit large and cumbersome, this gets us
    moving forward.
    
    Longer term, I'd love to see this stuff all refactored as a
    pipeline of sorts.

 plugins/autotools/ide-autotools-build-task.c |   96 ++++++++++++++++++++++++++
 plugins/autotools/ide-autotools-build-task.h |   10 +++
 plugins/autotools/ide-autotools-builder.c    |   14 ++--
 3 files changed, 113 insertions(+), 7 deletions(-)
---
diff --git a/plugins/autotools/ide-autotools-build-task.c b/plugins/autotools/ide-autotools-build-task.c
index 9712347..859ecd3 100644
--- a/plugins/autotools/ide-autotools-build-task.c
+++ b/plugins/autotools/ide-autotools-build-task.c
@@ -729,6 +729,102 @@ ide_autotools_build_task_execute_finish (IdeAutotoolsBuildTask  *self,
   IDE_RETURN (ret);
 }
 
+static void
+ide_autotools_build_task_postbuild_runtime_cb (GObject      *object,
+                                               GAsyncResult *result,
+                                               gpointer      user_data)
+{
+  IdeRuntime *runtime = (IdeRuntime *)object;
+  g_autoptr(GTask) task = user_data;
+  g_autoptr(GError) error = NULL;
+
+  g_assert (IDE_IS_RUNTIME (runtime));
+  g_assert (G_IS_ASYNC_RESULT (result));
+  g_assert (G_IS_TASK (task));
+
+  if (!ide_runtime_postbuild_finish (runtime, result, &error))
+    {
+      g_task_return_error (task, g_steal_pointer (&error));
+      return;
+    }
+
+  g_task_return_boolean (task, TRUE);
+}
+
+static void
+ide_autotools_build_task_execute_with_postbuild_cb (GObject      *object,
+                                                    GAsyncResult *result,
+                                                    gpointer      user_data)
+{
+  IdeAutotoolsBuildTask *self = (IdeAutotoolsBuildTask *)object;
+  g_autoptr(GTask) task = user_data;
+  g_autoptr(GError) error = NULL;
+  IdeRuntime *runtime;
+  GCancellable *cancellable;
+
+  g_assert (IDE_IS_AUTOTOOLS_BUILD_TASK (self));
+  g_assert (G_IS_ASYNC_RESULT (result));
+  g_assert (G_IS_TASK (task));
+
+  if (!ide_autotools_build_task_execute_finish (self, result, &error))
+    {
+      g_task_return_error (task, g_steal_pointer (&error));
+      return;
+    }
+
+  runtime = ide_configuration_get_runtime (self->configuration);
+
+  if (runtime == NULL)
+    {
+      g_task_return_new_error (task,
+                               G_IO_ERROR,
+                               G_IO_ERROR_NOT_SUPPORTED,
+                               "%s",
+                               _("Failed to access runtime for postbuild"));
+      return;
+    }
+
+  cancellable = g_task_get_cancellable (task);
+
+  ide_runtime_postbuild_async (runtime,
+                               cancellable,
+                               ide_autotools_build_task_postbuild_runtime_cb,
+                               g_steal_pointer (&task));
+}
+
+void
+ide_autotools_build_task_execute_with_postbuild (IdeAutotoolsBuildTask *self,
+                                                 IdeBuilderBuildFlags   flags,
+                                                 GCancellable          *cancellable,
+                                                 GAsyncReadyCallback    callback,
+                                                 gpointer               user_data)
+{
+  g_autoptr(GTask) task = NULL;
+
+  g_return_if_fail (IDE_IS_AUTOTOOLS_BUILD_TASK (self));
+  g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+  task = g_task_new (self, cancellable, callback, user_data);
+  g_task_set_source_tag (task, ide_autotools_build_task_execute_with_postbuild);
+
+  ide_autotools_build_task_execute_async (self,
+                                          flags,
+                                          cancellable,
+                                          ide_autotools_build_task_execute_with_postbuild_cb,
+                                          g_steal_pointer (&task));
+}
+
+gboolean
+ide_autotools_build_task_execute_with_postbuild_finish (IdeAutotoolsBuildTask  *self,
+                                                        GAsyncResult           *result,
+                                                        GError                **error)
+{
+  g_return_val_if_fail (IDE_IS_AUTOTOOLS_BUILD_TASK (self), FALSE);
+  g_return_val_if_fail (G_IS_TASK (result), FALSE);
+
+  return g_task_propagate_boolean (G_TASK (result), error);
+}
+
 static gboolean
 log_in_main (gpointer data)
 {
diff --git a/plugins/autotools/ide-autotools-build-task.h b/plugins/autotools/ide-autotools-build-task.h
index 3bc8a33..c0040c5 100644
--- a/plugins/autotools/ide-autotools-build-task.h
+++ b/plugins/autotools/ide-autotools-build-task.h
@@ -39,6 +39,16 @@ void      ide_autotools_build_task_execute_async  (IdeAutotoolsBuildTask  *self,
 gboolean  ide_autotools_build_task_execute_finish (IdeAutotoolsBuildTask  *self,
                                                    GAsyncResult           *result,
                                                    GError                **error);
+void      ide_autotools_build_task_execute_with_postbuild
+                                                  (IdeAutotoolsBuildTask  *self,
+                                                   IdeBuilderBuildFlags    flags,
+                                                   GCancellable           *cancellable,
+                                                   GAsyncReadyCallback     callback,
+                                                   gpointer                user_data);
+gboolean  ide_autotools_build_task_execute_with_postbuild_finish
+                                                  (IdeAutotoolsBuildTask  *self,
+                                                   GAsyncResult           *result,
+                                                   GError                **error);
 
 G_END_DECLS
 
diff --git a/plugins/autotools/ide-autotools-builder.c b/plugins/autotools/ide-autotools-builder.c
index 9efbbbe..6f20d06 100644
--- a/plugins/autotools/ide-autotools-builder.c
+++ b/plugins/autotools/ide-autotools-builder.c
@@ -41,7 +41,7 @@ ide_autotools_builder_build_cb (GObject      *object,
   g_return_if_fail (IDE_IS_AUTOTOOLS_BUILD_TASK (build_result));
   g_return_if_fail (G_IS_TASK (task));
 
-  if (!ide_autotools_build_task_execute_finish (build_result, result, &error))
+  if (!ide_autotools_build_task_execute_with_postbuild_finish (build_result, result, &error))
     {
       if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         ide_build_result_set_mode (IDE_BUILD_RESULT (build_result), _("Build cancelled"));
@@ -163,11 +163,11 @@ ide_autotools_builder_build_async (IdeBuilder           *builder,
   if (result != NULL)
     *result = g_object_ref (build_result);
 
-  ide_autotools_build_task_execute_async (build_result,
-                                          flags,
-                                          cancellable,
-                                          ide_autotools_builder_build_cb,
-                                          g_object_ref (task));
+  ide_autotools_build_task_execute_with_postbuild (build_result,
+                                                   flags,
+                                                   cancellable,
+                                                   ide_autotools_builder_build_cb,
+                                                   g_object_ref (task));
 }
 
 static IdeBuildResult *
@@ -195,7 +195,7 @@ ide_autotools_builder_install_cb (GObject      *object,
   g_assert (IDE_IS_AUTOTOOLS_BUILD_TASK (build_task));
   g_assert (G_IS_TASK (task));
 
-  if (!ide_autotools_build_task_execute_finish (build_task, result, &error))
+  if (!ide_autotools_build_task_execute_with_postbuild_finish (build_task, result, &error))
     {
       if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         ide_build_result_set_mode (IDE_BUILD_RESULT (build_task), _("Install cancelled"));


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