[gnome-builder] pipeline: add arch helper



commit 1f92cdca8f27c1f955db9987e76daca14e4999e9
Author: Christian Hergert <chergert redhat com>
Date:   Thu Feb 21 15:55:14 2019 -0800

    pipeline: add arch helper
    
    We can't always trust the arch specifically in a runtime object (as that
    might be one matching the host, not the target device). So add a helper
    that will check the device first and fallback to runtime.
    
    In the future, we should probably rename the flatpak runtimes to only
    use the name/version instead of arch too.

 src/libide/foundry/ide-pipeline.c | 44 +++++++++++++++++++++++++++++++++++++++
 src/libide/foundry/ide-pipeline.h |  4 ++++
 2 files changed, 48 insertions(+)
---
diff --git a/src/libide/foundry/ide-pipeline.c b/src/libide/foundry/ide-pipeline.c
index cd97517ec..ad64464d0 100644
--- a/src/libide/foundry/ide-pipeline.c
+++ b/src/libide/foundry/ide-pipeline.c
@@ -52,6 +52,7 @@
 #include "ide-runtime.h"
 #include "ide-toolchain-manager.h"
 #include "ide-toolchain.h"
+#include "ide-triplet.h"
 
 DZL_DEFINE_COUNTER (Instances, "Pipeline", "N Pipelines", "Number of Pipeline instances")
 G_DEFINE_QUARK (ide_build_error, ide_build_error)
@@ -150,6 +151,7 @@ struct _IdePipeline
    * strategy to get the compiled bits onto the device.
    */
   IdeDevice *device;
+  IdeDeviceInfo *device_info;
 
   /*
    * The cached triplet for the device we're compiling for. This allows
@@ -1334,6 +1336,7 @@ ide_pipeline_finalize (GObject *object)
   g_clear_object (&self->cancellable);
   g_clear_object (&self->log);
   g_clear_object (&self->device);
+  g_clear_object (&self->device_info);
   g_clear_object (&self->runtime);
   g_clear_object (&self->toolchain);
   g_clear_object (&self->config);
@@ -3963,6 +3966,8 @@ _ide_pipeline_check_toolchain (IdePipeline   *self,
   if (ide_object_in_destruction (IDE_OBJECT (self)))
     IDE_EXIT;
 
+  g_set_object (&self->device_info, info);
+
   context = ide_object_ref_context (IDE_OBJECT (self));
   g_return_if_fail (IDE_IS_CONTEXT (context));
 
@@ -4018,6 +4023,24 @@ ide_pipeline_get_device (IdePipeline *self)
   return self->device;
 }
 
+/**
+ * ide_pipeline_get_device_info:
+ * @self: a #IdePipeline
+ *
+ * Gets the device info for the current device.
+ *
+ * Returns: (nullable) (transfer none): an #IdeDeviceInfo or %NULL
+ *
+ * Since: 3.32
+ */
+IdeDeviceInfo *
+ide_pipeline_get_device_info (IdePipeline *self)
+{
+  g_return_val_if_fail (IDE_IS_PIPELINE (self), NULL);
+
+  return self->device_info;
+}
+
 /**
  * ide_pipeline_is_ready:
  * @self: a #IdePipeline
@@ -4080,3 +4103,24 @@ ide_pipeline_is_native (IdePipeline *self)
 
   return FALSE;
 }
+
+gchar *
+ide_pipeline_get_arch (IdePipeline *self)
+{
+  IdeRuntime *runtime;
+
+  g_return_val_if_fail (IDE_IS_PIPELINE (self), NULL);
+
+  if (self->device_info != NULL)
+    {
+      IdeTriplet *triplet;
+
+      if ((triplet = ide_device_info_get_host_triplet (self->device_info)))
+        return g_strdup (ide_triplet_get_arch (triplet));
+    }
+
+  if ((runtime = ide_pipeline_get_runtime (self)))
+    return ide_runtime_get_arch (runtime);
+
+  return NULL;
+}
diff --git a/src/libide/foundry/ide-pipeline.h b/src/libide/foundry/ide-pipeline.h
index 98081e555..902dd8b8e 100644
--- a/src/libide/foundry/ide-pipeline.h
+++ b/src/libide/foundry/ide-pipeline.h
@@ -77,6 +77,8 @@ G_DECLARE_FINAL_TYPE (IdePipeline, ide_pipeline, IDE, PIPELINE, IdeObject)
 IDE_AVAILABLE_IN_3_32
 GQuark                 ide_build_error_quark             (void) G_GNUC_CONST;
 IDE_AVAILABLE_IN_3_32
+gchar                 *ide_pipeline_get_arch             (IdePipeline            *self);
+IDE_AVAILABLE_IN_3_32
 gboolean               ide_pipeline_is_native            (IdePipeline            *self);
 IDE_AVAILABLE_IN_3_32
 gboolean               ide_pipeline_is_ready             (IdePipeline            *self);
@@ -87,6 +89,8 @@ IdeConfig             *ide_pipeline_get_config           (IdePipeline
 IDE_AVAILABLE_IN_3_32
 IdeDevice             *ide_pipeline_get_device           (IdePipeline            *self);
 IDE_AVAILABLE_IN_3_32
+IdeDeviceInfo         *ide_pipeline_get_device_info      (IdePipeline            *self);
+IDE_AVAILABLE_IN_3_32
 IdeTriplet            *ide_pipeline_get_host_triplet     (IdePipeline            *self);
 IDE_AVAILABLE_IN_3_32
 IdeRuntime            *ide_pipeline_get_runtime          (IdePipeline            *self);


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