[gnome-builder] foundry: add API to check config for programs



commit 14de9428d02e13378bf8d62bee5afd2ddc58562c
Author: Christian Hergert <chergert redhat com>
Date:   Thu Aug 1 17:10:42 2019 -0700

    foundry: add API to check config for programs
    
    This allows checking a build pipeline for program availability. It will
    check the current runtime as well as the SDK extensions if any.

 src/libide/foundry/ide-pipeline.c | 51 +++++++++++++++++++++++++++++++++++++++
 src/libide/foundry/ide-pipeline.h |  4 +++
 2 files changed, 55 insertions(+)
---
diff --git a/src/libide/foundry/ide-pipeline.c b/src/libide/foundry/ide-pipeline.c
index cbcad1539..bfd4ed268 100644
--- a/src/libide/foundry/ide-pipeline.c
+++ b/src/libide/foundry/ide-pipeline.c
@@ -4189,3 +4189,54 @@ ide_pipeline_get_arch (IdePipeline *self)
 
   return NULL;
 }
+
+/**
+ * ide_pipeline_contains_program_in_path:
+ * @self: a #IdePipeline
+ * @name: the name of a binary
+ *
+ * Looks through the runtime and SDK extensions for binaries matching
+ * @name that may be executed.
+ *
+ * Returns: %TRUE if @name was found; otherwise %FALSE
+ *
+ * Since: 3.34
+ */
+gboolean
+ide_pipeline_contains_program_in_path (IdePipeline  *self,
+                                       const gchar  *name,
+                                       GCancellable *cancellable)
+{
+  g_return_val_if_fail (IDE_IS_PIPELINE (self), FALSE);
+  g_return_val_if_fail (name != NULL, FALSE);
+  g_return_val_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable), FALSE);
+
+  if (self->runtime != NULL)
+    {
+      if (ide_runtime_contains_program_in_path (self->runtime, name, cancellable))
+        return TRUE;
+    }
+
+  if (self->config != NULL)
+    {
+      g_autoptr(GPtrArray) ar = NULL;
+
+      if (g_cancellable_is_cancelled (cancellable))
+        return FALSE;
+
+      ar = ide_config_get_extensions (self->config);
+      IDE_PTR_ARRAY_SET_FREE_FUNC (ar, g_object_unref);
+
+      for (guint i = 0; i < ar->len; i++)
+        {
+          IdeRuntime *runtime = g_ptr_array_index (ar, i);
+
+          g_assert (IDE_IS_RUNTIME (runtime));
+
+          if (ide_runtime_contains_program_in_path (self->runtime, name, cancellable))
+            return TRUE;
+        }
+    }
+
+  return FALSE;
+}
diff --git a/src/libide/foundry/ide-pipeline.h b/src/libide/foundry/ide-pipeline.h
index 902dd8b8e..7004590c3 100644
--- a/src/libide/foundry/ide-pipeline.h
+++ b/src/libide/foundry/ide-pipeline.h
@@ -214,5 +214,9 @@ IDE_AVAILABLE_IN_3_32
 gboolean               ide_pipeline_has_configured       (IdePipeline            *self);
 IDE_AVAILABLE_IN_3_32
 IdePipelinePhase       ide_pipeline_get_requested_phase  (IdePipeline            *self);
+IDE_AVAILABLE_IN_3_34
+gboolean               ide_pipeline_contains_program_in_path (IdePipeline            *self,
+                                                              const gchar            *name,
+                                                              GCancellable           *cancellable);
 
 G_END_DECLS


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