[gnome-builder] flatpak: add helper to get impacted runtimes



commit d664c1740ee2858e1a064a336940ca2124075c76
Author: Christian Hergert <chergert redhat com>
Date:   Wed Mar 13 23:16:57 2019 -0700

    flatpak: add helper to get impacted runtimes
    
    This is a helper to determine all of the runtimes that might be
    needed to service the manifest.

 src/plugins/flatpak/gbp-flatpak-manifest.c | 48 ++++++++++++++++++++++++++++++
 src/plugins/flatpak/gbp-flatpak-manifest.h |  2 ++
 2 files changed, 50 insertions(+)
---
diff --git a/src/plugins/flatpak/gbp-flatpak-manifest.c b/src/plugins/flatpak/gbp-flatpak-manifest.c
index 194517f73..f32d7f20e 100644
--- a/src/plugins/flatpak/gbp-flatpak-manifest.c
+++ b/src/plugins/flatpak/gbp-flatpak-manifest.c
@@ -21,6 +21,7 @@
 
 #define G_LOG_DOMAIN "gbp-flatpak-manifest"
 
+#include <flatpak/flatpak.h>
 #include <json-glib/json-glib.h>
 
 #include "gbp-flatpak-manifest.h"
@@ -996,3 +997,50 @@ gbp_flatpak_manifest_save_finish (GbpFlatpakManifest  *self,
 
   IDE_RETURN (ret);
 }
+
+gchar **
+gbp_flatpak_manifest_get_runtimes (GbpFlatpakManifest *self,
+                                   const gchar        *for_arch)
+{
+  const gchar *runtime_version = "master";
+  const gchar *sdk;
+  GPtrArray *ar;
+
+  g_return_val_if_fail (GBP_IS_FLATPAK_MANIFEST (self), NULL);
+
+  ar = g_ptr_array_new ();
+
+  if (for_arch != NULL)
+    for_arch = flatpak_get_default_arch ();
+
+  if (self->runtime_version != NULL)
+    runtime_version = self->runtime_version;
+
+  if (self->sdk == NULL)
+    sdk = self->runtime;
+  else
+    sdk = self->sdk;
+
+  /* First discover the runtime needed for building */
+  g_ptr_array_add (ar, g_strdup_printf ("%s/%s/%s", sdk, for_arch, runtime_version));
+
+  /* Now add the documentation SDK so the user can get docs */
+  g_ptr_array_add (ar, g_strdup_printf ("%s.Docs/%s/%s", sdk, for_arch, runtime_version));
+
+  /* Now discover the runtime needed for running */
+  g_ptr_array_add (ar, g_strdup_printf ("%s/%s/%s", self->runtime, for_arch, runtime_version));
+
+  /* Now discover any necessary SDK extensions */
+  if (self->sdk_extensions != NULL)
+    {
+      for (guint i = 0; self->sdk_extensions[i]; i++)
+        g_ptr_array_add (ar, g_strdup_printf ("%s/%s/%s",
+                                              self->sdk_extensions[i],
+                                              for_arch,
+                                              runtime_version));
+    }
+
+  g_ptr_array_add (ar, NULL);
+
+  return (gchar **)g_ptr_array_free (ar, FALSE);
+}
diff --git a/src/plugins/flatpak/gbp-flatpak-manifest.h b/src/plugins/flatpak/gbp-flatpak-manifest.h
index e4a33746b..4ff84f44e 100644
--- a/src/plugins/flatpak/gbp-flatpak-manifest.h
+++ b/src/plugins/flatpak/gbp-flatpak-manifest.h
@@ -39,6 +39,8 @@ const gchar * const *gbp_flatpak_manifest_get_build_args     (GbpFlatpakManifest
 const gchar * const *gbp_flatpak_manifest_get_finish_args    (GbpFlatpakManifest   *self);
 const gchar * const *gbp_flatpak_manifest_get_sdk_extensions (GbpFlatpakManifest   *self);
 const gchar         *gbp_flatpak_manifest_get_sdk            (GbpFlatpakManifest   *self);
+gchar              **gbp_flatpak_manifest_get_runtimes       (GbpFlatpakManifest   *self,
+                                                              const gchar          *for_arch);
 void                 gbp_flatpak_manifest_save_async         (GbpFlatpakManifest   *self,
                                                               GCancellable         *cancellable,
                                                               GAsyncReadyCallback   callback,


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