[gnome-builder/wip/gtk4-port] libide/foundry: add vfunc to create run context from runtime



commit 50bc200d0ee0aea1ff1bf16ed0f62861632ff8aa
Author: Christian Hergert <chergert redhat com>
Date:   Fri Jun 17 11:36:35 2022 -0700

    libide/foundry: add vfunc to create run context from runtime
    
    The goal here is to replace IdeRunner, so things like the flatpak runtime
    would start by creating the context (and pushing a handler that can
    prepend "flatpak build ..." and translate environment variables, etc.

 src/libide/foundry/ide-runtime.c | 34 ++++++++++++++++++++++++++++++----
 src/libide/foundry/ide-runtime.h |  5 ++++-
 2 files changed, 34 insertions(+), 5 deletions(-)
---
diff --git a/src/libide/foundry/ide-runtime.c b/src/libide/foundry/ide-runtime.c
index a1fdf8dd9..235a6bf5c 100644
--- a/src/libide/foundry/ide-runtime.c
+++ b/src/libide/foundry/ide-runtime.c
@@ -35,6 +35,7 @@
 #include "ide-build-target.h"
 #include "ide-config.h"
 #include "ide-config-manager.h"
+#include "ide-run-context.h"
 #include "ide-runtime.h"
 #include "ide-runner.h"
 #include "ide-toolchain.h"
@@ -82,15 +83,23 @@ ide_runtime_real_create_launcher (IdeRuntime  *self,
     }
   else
     {
-      g_set_error (error,
-                   G_IO_ERROR,
-                   G_IO_ERROR_FAILED,
-                   "An unknown error ocurred");
+      g_set_error_literal (error,
+                           G_IO_ERROR,
+                           G_IO_ERROR_FAILED,
+                           "An unknown error ocurred");
     }
 
   IDE_RETURN (ret);
 }
 
+static IdeRunContext *
+ide_runtime_real_create_run_context (IdeRuntime *self)
+{
+  g_assert (IDE_IS_RUNTIME (self));
+
+  return ide_run_context_new ();
+}
+
 static gboolean
 ide_runtime_real_contains_program_in_path (IdeRuntime   *self,
                                            const gchar  *program,
@@ -449,6 +458,7 @@ ide_runtime_class_init (IdeRuntimeClass *klass)
   i_object_class->repr = ide_runtime_repr;
 
   klass->create_launcher = ide_runtime_real_create_launcher;
+  klass->create_run_context = ide_runtime_real_create_run_context;
   klass->create_runner = ide_runtime_real_create_runner;
   klass->contains_program_in_path = ide_runtime_real_contains_program_in_path;
   klass->prepare_configuration = ide_runtime_real_prepare_configuration;
@@ -855,3 +865,19 @@ ide_runtime_supports_toolchain (IdeRuntime   *self,
 
   return TRUE;
 }
+
+/**
+ * ide_runtime_create_run_context:
+ * @self: a #IdeRuntime
+ *
+ * Creates a new #IdeRunContext for the runtime.
+ *
+ * Returns: (transfer full): an #IdeRunContext
+ */
+IdeRunContext *
+ide_runtime_create_run_context (IdeRuntime *self)
+{
+  g_return_val_if_fail (IDE_IS_RUNTIME (self), NULL);
+
+  return IDE_RUNTIME_GET_CLASS (self)->create_run_context (self);
+}
diff --git a/src/libide/foundry/ide-runtime.h b/src/libide/foundry/ide-runtime.h
index ccc0a43b2..51b9458f6 100644
--- a/src/libide/foundry/ide-runtime.h
+++ b/src/libide/foundry/ide-runtime.h
@@ -55,7 +55,8 @@ struct _IdeRuntimeClass
   IdeSubprocessLauncher  *(*create_launcher)          (IdeRuntime           *self,
                                                        GError              **error);
   void                    (*prepare_configuration)    (IdeRuntime           *self,
-                                                       IdeConfig     *configuration);
+                                                       IdeConfig            *config);
+  IdeRunContext          *(*create_run_context)       (IdeRuntime           *self);
   IdeRunner              *(*create_runner)            (IdeRuntime           *self,
                                                        IdeBuildTarget       *build_target);
   GFile                  *(*translate_file)           (IdeRuntime           *self,
@@ -79,6 +80,8 @@ IDE_AVAILABLE_IN_ALL
 IdeSubprocessLauncher  *ide_runtime_create_launcher          (IdeRuntime      *self,
                                                               GError         **error);
 IDE_AVAILABLE_IN_ALL
+IdeRunContext          *ide_runtime_create_run_context       (IdeRuntime      *self);
+IDE_AVAILABLE_IN_ALL
 IdeRunner              *ide_runtime_create_runner            (IdeRuntime      *self,
                                                               IdeBuildTarget  *build_target);
 IDE_AVAILABLE_IN_ALL


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