[gnome-builder/wip/gtk4-port] libide/foundry: add API to setup run context for pipeline



commit f87a79705e6440d143d261cbcf27fcbd3920dcc2
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jun 22 16:55:47 2022 -0700

    libide/foundry: add API to setup run context for pipeline
    
    The goal here is to setup the run context similarly to when we are running
    applications, but in the format that we'd expect for build pipelines. This
    can be used by shellcmd to run "differently based on locality".
    
    We still need the runtime plumbing to differentiate though.

 src/libide/foundry/ide-pipeline.c | 24 ++++++++++++++++++++++++
 src/libide/foundry/ide-pipeline.h |  3 +++
 2 files changed, 27 insertions(+)
---
diff --git a/src/libide/foundry/ide-pipeline.c b/src/libide/foundry/ide-pipeline.c
index 8ae1e6956..87da08715 100644
--- a/src/libide/foundry/ide-pipeline.c
+++ b/src/libide/foundry/ide-pipeline.c
@@ -50,6 +50,7 @@
 #include "ide-foundry-enums.h"
 #include "ide-local-deploy-strategy.h"
 #include "ide-local-device.h"
+#include "ide-run-context.h"
 #include "ide-run-manager-private.h"
 #include "ide-runtime.h"
 #include "ide-toolchain-manager.h"
@@ -4350,3 +4351,26 @@ ide_pipeline_addin_find_by_module_name (IdePipeline *pipeline,
 
   return IDE_PIPELINE_ADDIN (ret);
 }
+
+void
+ide_pipeline_prepare_run_context (IdePipeline   *self,
+                                  IdeRunContext *run_context)
+{
+  IdeRuntime *runtime;
+
+  g_return_if_fail (IDE_IS_MAIN_THREAD ());
+  g_return_if_fail (IDE_IS_PIPELINE (self));
+  g_return_if_fail (IDE_IS_RUN_CONTEXT (run_context));
+
+  if (!(runtime = ide_pipeline_get_runtime (self)))
+    {
+      g_critical ("Attempt to prepare a run context before pipeline has a runtime!");
+      return;
+    }
+
+  /* TODO: setup run context for building instead of running */
+  ide_runtime_prepare_run_context (runtime, run_context);
+
+  ide_run_context_setenv (run_context, "BUILDDIR", ide_pipeline_get_builddir (self));
+  ide_run_context_setenv (run_context, "SRCDIR", ide_pipeline_get_srcdir (self));
+}
diff --git a/src/libide/foundry/ide-pipeline.h b/src/libide/foundry/ide-pipeline.h
index 8812cec51..7adc3aa16 100644
--- a/src/libide/foundry/ide-pipeline.h
+++ b/src/libide/foundry/ide-pipeline.h
@@ -92,6 +92,9 @@ IDE_AVAILABLE_IN_ALL
 IdeSubprocessLauncher *ide_pipeline_create_launcher          (IdePipeline            *self,
                                                               GError                **error);
 IDE_AVAILABLE_IN_ALL
+void                   ide_pipeline_prepare_run_context      (IdePipeline            *self,
+                                                              IdeRunContext          *run_context);
+IDE_AVAILABLE_IN_ALL
 gchar                 *ide_pipeline_build_srcdir_path        (IdePipeline            *self,
                                                               const gchar            *first_part,
                                                               ...) G_GNUC_NULL_TERMINATED;


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