[gnome-builder] pipeline: add helper to check if configured



commit 4107037c7de091c262a2ec96eb4dc1ec8bb38a47
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 10 23:26:18 2018 -0800

    pipeline: add helper to check if configured
    
    There are times we want to know that the project has been configured. This
    simplifies that case instead of always requiring that the pipeline be
    advanced.

 src/libide/buildsystem/ide-build-pipeline.c |   68 +++++++++++++++++++++++++++
 src/libide/buildsystem/ide-build-pipeline.h |    2 +
 2 files changed, 70 insertions(+), 0 deletions(-)
---
diff --git a/src/libide/buildsystem/ide-build-pipeline.c b/src/libide/buildsystem/ide-build-pipeline.c
index 6e7e6d6..103aa3b 100644
--- a/src/libide/buildsystem/ide-build-pipeline.c
+++ b/src/libide/buildsystem/ide-build-pipeline.c
@@ -3090,3 +3090,71 @@ _ide_build_pipeline_cancel (IdeBuildPipeline *self)
   self->cancellable = g_cancellable_new ();
   g_cancellable_cancel (cancellable);
 }
+
+/**
+ * ide_build_pipeline_has_configured:
+ * @self: a #IdeBuildPipeline
+ *
+ * Checks to see if the pipeline has advanced far enough to ensure that
+ * the configure stage has been reached.
+ *
+ * Returns: %TRUE if %IDE_BUILD_PHASE_CONFIGURE has been reached.
+ *
+ * Since: 3.28
+ */
+gboolean
+ide_build_pipeline_has_configured (IdeBuildPipeline *self)
+{
+  g_return_val_if_fail (IDE_IS_BUILD_PIPELINE (self), FALSE);
+
+  /*
+   * We need to walk from beginning towards end (instead of
+   * taking a cleaner approach that would be to walk from the
+   * end forward) because it's possible for some items to be
+   * marked completed before they've ever been run.
+   *
+   * So just walk forward and we have configured if we hit
+   * any phase that is CONFIGURE and has completed, or no
+   * configure phases were found.
+   */
+
+  for (guint i = 0; i < self->pipeline->len; i++)
+    {
+      const PipelineEntry *entry = &g_array_index (self->pipeline, PipelineEntry, i);
+
+      if ((entry->phase & IDE_BUILD_PHASE_MASK) < IDE_BUILD_PHASE_CONFIGURE)
+        continue;
+
+      if (entry->phase & IDE_BUILD_PHASE_CONFIGURE)
+        {
+          /*
+           * This is a configure phase, ensure that it has been
+           * completed, or we have not really configured.
+           */
+          if (!ide_build_stage_get_completed (entry->stage))
+            return FALSE;
+
+          /*
+           * Check the next pipeline entry to ensure that it too
+           * has been configured.
+           */
+          continue;
+        }
+
+      /*
+       * We've advanced past CONFIGURE, so anything at this point
+       * can be considered configured.
+       */
+
+      return TRUE;
+    }
+
+  /*
+   * Technically we could have a build system that only supports
+   * up to configure. But I don't really care about that case. If
+   * that ever happens, we need an additional check here that the
+   * last pipeline entry completed.
+   */
+
+  return FALSE;
+}
diff --git a/src/libide/buildsystem/ide-build-pipeline.h b/src/libide/buildsystem/ide-build-pipeline.h
index 5509843..abd7da2 100644
--- a/src/libide/buildsystem/ide-build-pipeline.h
+++ b/src/libide/buildsystem/ide-build-pipeline.h
@@ -169,5 +169,7 @@ gboolean               ide_build_pipeline_rebuild_finish      (IdeBuildPipeline
 IDE_AVAILABLE_IN_3_28
 void                   ide_build_pipeline_attach_pty          (IdeBuildPipeline       *self,
                                                                IdeSubprocessLauncher  *launcher);
+IDE_AVAILABLE_IN_3_28
+gboolean               ide_build_pipeline_has_configured      (IdeBuildPipeline       *self);
 
 G_END_DECLS


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