[gnome-builder/gnome-builder-43] libide/foundry: apply config environment to run context



commit dec93ff305929136bc315da43ed53ae9aa698874
Author: Christian Hergert <chergert redhat com>
Date:   Sun Sep 18 17:18:06 2022 -0700

    libide/foundry: apply config environment to run context
    
    We don't want to require this to be done per-runtime, so apply it for all
    runtimes as part of the prepare-to-build pipeline process.
    
    Fixes #1792

 src/libide/foundry/ide-pipeline.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/src/libide/foundry/ide-pipeline.c b/src/libide/foundry/ide-pipeline.c
index 0ca2e29fd..0d8f3a03f 100644
--- a/src/libide/foundry/ide-pipeline.c
+++ b/src/libide/foundry/ide-pipeline.c
@@ -4431,6 +4431,7 @@ ide_pipeline_prepare_run_context (IdePipeline   *self,
                                   IdeRunContext *run_context)
 {
   IdeRuntime *runtime;
+  IdeEnvironment *env;
 
   g_return_if_fail (IDE_IS_MAIN_THREAD ());
   g_return_if_fail (IDE_IS_PIPELINE (self));
@@ -4444,9 +4445,24 @@ ide_pipeline_prepare_run_context (IdePipeline   *self,
 
   ide_runtime_prepare_to_build (runtime, self, run_context);
 
+  ide_run_context_set_cwd (run_context, ide_pipeline_get_builddir (self));
+
   ide_run_context_setenv (run_context, "BUILDDIR", ide_pipeline_get_builddir (self));
   ide_run_context_setenv (run_context, "SRCDIR", ide_pipeline_get_srcdir (self));
-  ide_run_context_set_cwd (run_context, ide_pipeline_get_builddir (self));
+
+  if ((env = ide_config_get_environment (self->config)))
+    {
+      guint n_items = g_list_model_get_n_items (G_LIST_MODEL (env));
+
+      for (guint i = 0; i < n_items; i++)
+        {
+          g_autoptr(IdeEnvironmentVariable) envvar = g_list_model_get_item (G_LIST_MODEL (env), i);
+
+          ide_run_context_setenv (run_context,
+                                  ide_environment_variable_get_key (envvar),
+                                  ide_environment_variable_get_value (envvar));
+        }
+    }
 }
 
 /**


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