[gnome-builder] runner: add IdeRunner:clear-env
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] runner: add IdeRunner:clear-env
- Date: Wed, 14 Sep 2016 08:23:09 +0000 (UTC)
commit c0f3d549641ea52a2b0d88baad1b1a675033a1f3
Author: Christian Hergert <chergert redhat com>
Date: Wed Sep 14 00:08:02 2016 -0700
runner: add IdeRunner:clear-env
This helps us be able to reuse subprocess launchers that are also created
by the IdeRuntime. That should simplify other uses in the future.
libide/runner/ide-runner.c | 67 ++++++++++++++++++++++++++++++++++++++++++-
libide/runner/ide-runner.h | 3 ++
2 files changed, 68 insertions(+), 2 deletions(-)
---
diff --git a/libide/runner/ide-runner.c b/libide/runner/ide-runner.c
index a59ba7f..2f427cb 100644
--- a/libide/runner/ide-runner.c
+++ b/libide/runner/ide-runner.c
@@ -25,8 +25,11 @@
#include "ide-context.h"
#include "ide-debug.h"
+#include "buildsystem/ide-configuration.h"
+#include "buildsystem/ide-configuration-manager.h"
#include "runner/ide-runner.h"
#include "runner/ide-runner-addin.h"
+#include "runtimes/ide-runtime.h"
#include "subprocess/ide-subprocess.h"
#include "subprocess/ide-subprocess-launcher.h"
@@ -36,6 +39,7 @@ typedef struct
GQueue argv;
IdeEnvironment *env;
GSubprocessFlags flags;
+ guint clear_env : 1;
guint run_on_host : 1;
} IdeRunnerPrivate;
@@ -48,6 +52,7 @@ typedef struct
enum {
PROP_0,
PROP_ARGV,
+ PROP_CLEAR_ENV,
PROP_ENV,
PROP_RUN_ON_HOST,
N_PROPS
@@ -158,7 +163,11 @@ ide_runner_real_run_async (IdeRunner *self,
g_autoptr(IdeSubprocessLauncher) launcher = NULL;
g_autoptr(IdeSubprocess) subprocess = NULL;
g_auto(GStrv) environ = NULL;
+ IdeConfigurationManager *config_manager;
+ IdeConfiguration *config;
const gchar *identifier;
+ IdeContext *context;
+ IdeRuntime *runtime;
GError *error = NULL;
IDE_ENTRY;
@@ -169,7 +178,19 @@ ide_runner_real_run_async (IdeRunner *self,
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, ide_runner_real_run_async);
- launcher = ide_subprocess_launcher_new (priv->flags);
+ context = ide_object_get_context (IDE_OBJECT (self));
+ config_manager = ide_context_get_configuration_manager (context);
+ config = ide_configuration_manager_get_current (config_manager);
+ runtime = ide_configuration_get_runtime (config);
+
+
+ if (runtime != NULL)
+ launcher = ide_runtime_create_launcher (runtime, NULL);
+
+ if (launcher == NULL)
+ launcher = ide_subprocess_launcher_new (0);
+
+ ide_subprocess_launcher_set_flags (launcher, priv->flags);
/*
* We want the runners to run on the host so that we aren't captive to
@@ -181,7 +202,7 @@ ide_runner_real_run_async (IdeRunner *self,
* We don't want the environment cleared because we need access to
* things like DISPLAY, WAYLAND_DISPLAY, and DBUS_SESSION_BUS_ADDRESS.
*/
- ide_subprocess_launcher_set_clear_env (launcher, FALSE);
+ ide_subprocess_launcher_set_clear_env (launcher, priv->clear_env);
/*
* Overlay the environment provided.
@@ -324,6 +345,10 @@ ide_runner_get_property (GObject *object,
g_value_take_boxed (value, ide_runner_get_argv (self));
break;
+ case PROP_CLEAR_ENV:
+ g_value_set_boolean (value, ide_runner_get_clear_env (self));
+ break;
+
case PROP_ENV:
g_value_set_object (value, ide_runner_get_environment (self));
break;
@@ -351,6 +376,10 @@ ide_runner_set_property (GObject *object,
ide_runner_set_argv (self, g_value_get_boxed (value));
break;
+ case PROP_CLEAR_ENV:
+ ide_runner_set_clear_env (self, g_value_get_boolean (value));
+ break;
+
case PROP_RUN_ON_HOST:
ide_runner_set_run_on_host (self, g_value_get_boolean (value));
break;
@@ -380,6 +409,13 @@ ide_runner_class_init (IdeRunnerClass *klass)
G_TYPE_STRV,
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
+ properties [PROP_CLEAR_ENV] =
+ g_param_spec_boolean ("clear-env",
+ "Clear Env",
+ "If the environment should be cleared before applying overrides",
+ FALSE,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
properties [PROP_ENV] =
g_param_spec_object ("environment",
"Environment",
@@ -806,3 +842,30 @@ ide_runner_set_flags (IdeRunner *self,
priv->flags = flags;
}
+
+gboolean
+ide_runner_get_clear_env (IdeRunner *self)
+{
+ IdeRunnerPrivate *priv = ide_runner_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_RUNNER (self), FALSE);
+
+ return priv->clear_env;
+}
+
+void
+ide_runner_set_clear_env (IdeRunner *self,
+ gboolean clear_env)
+{
+ IdeRunnerPrivate *priv = ide_runner_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_RUNNER (self));
+
+ clear_env = !!clear_env;
+
+ if (clear_env != priv->clear_env)
+ {
+ priv->clear_env = clear_env;
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_CLEAR_ENV]);
+ }
+}
diff --git a/libide/runner/ide-runner.h b/libide/runner/ide-runner.h
index 19444d6..a6ab281 100644
--- a/libide/runner/ide-runner.h
+++ b/libide/runner/ide-runner.h
@@ -59,6 +59,9 @@ gboolean ide_runner_run_finish (IdeRunner *self,
GError **error);
void ide_runner_set_flags (IdeRunner *self,
GSubprocessFlags flags);
+gboolean ide_runner_get_clear_env (IdeRunner *self);
+void ide_runner_set_clear_env (IdeRunner *self,
+ gboolean clear_env);
void ide_runner_prepend_argv (IdeRunner *self,
const gchar *param);
void ide_runner_append_argv (IdeRunner *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]