[gnome-builder/runtime_environment] environment: add runtime environment
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/runtime_environment] environment: add runtime environment
- Date: Wed, 14 Oct 2020 14:54:20 +0000 (UTC)
commit 502e35af47c0bf543ad50ef35a7aac643cd9f07f
Author: Julian Sparber <julian sparber net>
Date: Wed Oct 14 16:30:05 2020 +0200
environment: add runtime environment
This adds a runtime environment so that the user can specify runtime
environment variables seperate from the build variables.
Fixes: https://gitlab.gnome.org/GNOME/gnome-builder/-/issues/544
src/libide/foundry/ide-config.c | 70 ++++++++++++++++++++++
src/libide/foundry/ide-config.h | 5 ++
src/libide/foundry/ide-run-manager.c | 7 +--
.../buildui/gbp-buildui-config-view-addin.c | 14 +++++
4 files changed, 90 insertions(+), 6 deletions(-)
---
diff --git a/src/libide/foundry/ide-config.c b/src/libide/foundry/ide-config.c
index cb09336b9..46c8123ca 100644
--- a/src/libide/foundry/ide-config.c
+++ b/src/libide/foundry/ide-config.c
@@ -51,6 +51,7 @@ typedef struct
GFile *build_commands_dir;
IdeEnvironment *environment;
+ IdeEnvironment *runtime_environment;
GHashTable *internal;
@@ -252,6 +253,24 @@ ide_config_environment_changed (IdeConfig *self,
IDE_EXIT;
}
+static void
+ide_config_runtime_environment_changed (IdeConfig *self,
+ IdeEnvironment *environment)
+{
+ IDE_ENTRY;
+
+ g_assert (IDE_IS_CONFIG (self));
+ g_assert (IDE_IS_ENVIRONMENT (environment));
+
+ if (ide_object_in_destruction (IDE_OBJECT (self)))
+ return;
+
+ ide_config_set_dirty (self, TRUE);
+ ide_config_emit_changed (self);
+
+ IDE_EXIT;
+}
+
static void
ide_config_real_set_runtime (IdeConfig *self,
IdeRuntime *runtime)
@@ -291,6 +310,7 @@ ide_config_finalize (GObject *object)
g_clear_object (&priv->build_commands_dir);
g_clear_object (&priv->environment);
+ g_clear_object (&priv->runtime_environment);
g_clear_pointer (&priv->build_commands, g_strfreev);
g_clear_pointer (&priv->internal, g_hash_table_unref);
@@ -667,6 +687,7 @@ ide_config_init (IdeConfig *self)
{
IdeConfigPrivate *priv = ide_config_get_instance_private (self);
g_autoptr(IdeEnvironment) env = ide_environment_new ();
+ g_autoptr(IdeEnvironment) rt_env = ide_environment_new ();
priv->runtime_id = g_strdup ("host");
priv->toolchain_id = g_strdup ("default");
@@ -676,6 +697,7 @@ ide_config_init (IdeConfig *self)
priv->internal = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, _value_free);
ide_config_set_environment (self, env);
+ ide_config_set_runtime_environment (self, rt_env);
}
/**
@@ -1165,6 +1187,54 @@ ide_config_set_environment (IdeConfig *self,
}
}
+/**
+ * ide_config_get_runtime_environment:
+ *
+ * Returns: (transfer none): An #IdeEnvironment.
+ *
+ * Since: 3.40
+ */
+IdeEnvironment *
+ide_config_get_runtime_environment (IdeConfig *self)
+{
+ IdeConfigPrivate *priv = ide_config_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_CONFIG (self), NULL);
+
+ return priv->runtime_environment;
+}
+
+void
+ide_config_set_runtime_environment (IdeConfig *self,
+ IdeEnvironment *environment)
+{
+ IdeConfigPrivate *priv = ide_config_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_CONFIG (self));
+ g_return_if_fail (!environment || IDE_IS_ENVIRONMENT (environment));
+
+ if (priv->runtime_environment != environment)
+ {
+ if (priv->runtime_environment != NULL)
+ {
+ g_signal_handlers_disconnect_by_func (priv->runtime_environment,
+ G_CALLBACK (ide_config_runtime_environment_changed),
+ self);
+ g_clear_object (&priv->runtime_environment);
+ }
+
+ if (environment != NULL)
+ {
+ priv->runtime_environment = g_object_ref (environment);
+ g_signal_connect_object (priv->runtime_environment,
+ "changed",
+ G_CALLBACK (ide_config_runtime_environment_changed),
+ self,
+ G_CONNECT_SWAPPED);
+ }
+ }
+}
+
const gchar *
ide_config_get_config_opts (IdeConfig *self)
{
diff --git a/src/libide/foundry/ide-config.h b/src/libide/foundry/ide-config.h
index 6eedd5c57..da56feba2 100644
--- a/src/libide/foundry/ide-config.h
+++ b/src/libide/foundry/ide-config.h
@@ -161,6 +161,11 @@ IdeEnvironment *ide_config_get_environment (IdeConfig
IDE_AVAILABLE_IN_3_32
void ide_config_set_environment (IdeConfig *self,
IdeEnvironment *environment);
+IDE_AVAILABLE_IN_3_40
+IdeEnvironment *ide_config_get_runtime_environment (IdeConfig *self);
+IDE_AVAILABLE_IN_3_40
+void ide_config_set_runtime_environment (IdeConfig *self,
+ IdeEnvironment *environment);
IDE_AVAILABLE_IN_3_32
guint ide_config_get_sequence (IdeConfig *self);
IDE_AVAILABLE_IN_3_32
diff --git a/src/libide/foundry/ide-run-manager.c b/src/libide/foundry/ide-run-manager.c
index c5de0c44d..fe34f8de0 100644
--- a/src/libide/foundry/ide-run-manager.c
+++ b/src/libide/foundry/ide-run-manager.c
@@ -509,16 +509,11 @@ do_run_async (IdeRunManager *self,
}
}
- /* Add our environment variables. Currently, these are coming
- * from the *build* environment because we do not yet have a
- * way to differentiate between build environment and runtime
- * for the application.
- */
environment = ide_runner_get_environment (runner);
/* FIXME: Allow toggling this in build prefs */
ide_environment_setenv (environment, "G_MESSAGES_DEBUG", "all");
copy_builtin_envvars (environment);
- ide_environment_copy_into (ide_config_get_environment (config), environment, TRUE);
+ ide_environment_copy_into (ide_config_get_runtime_environment (config), environment, TRUE);
g_signal_emit (self, signals [RUN], 0, runner);
diff --git a/src/plugins/buildui/gbp-buildui-config-view-addin.c
b/src/plugins/buildui/gbp-buildui-config-view-addin.c
index dd387a1a6..af054d017 100644
--- a/src/plugins/buildui/gbp-buildui-config-view-addin.c
+++ b/src/plugins/buildui/gbp-buildui-config-view-addin.c
@@ -427,6 +427,7 @@ gbp_buildui_config_view_addin_load (IdeConfigViewAddin *addin,
dzl_preferences_add_list_group (preferences, "general", "general", _("Overview"), GTK_SELECTION_NONE, 0);
dzl_preferences_add_group (preferences, "general", "buttons", NULL, 0);
dzl_preferences_add_group (preferences, "environ", "build", _("Build Environment"), 0);
+ dzl_preferences_add_group (preferences, "environ", "runtime", _("Runtime Environment"), 0);
/* actions button box */
box = g_object_new (GTK_TYPE_BOX,
@@ -495,6 +496,19 @@ gbp_buildui_config_view_addin_load (IdeConfigViewAddin *addin,
NULL),
NULL),
NULL, 0);
+
+ /* Add runtime environment selector */
+ environ_ = ide_config_get_runtime_environment (config);
+ dzl_preferences_add_custom (preferences, "environ", "runtime",
+ g_object_new (GTK_TYPE_FRAME,
+ "visible", TRUE,
+ "child", g_object_new (IDE_TYPE_ENVIRONMENT_EDITOR,
+ "environment", environ_,
+ "visible", TRUE,
+ NULL),
+ NULL),
+ NULL, 0);
+
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]