[gnome-builder] flatpak: Support prepend-path build option
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] flatpak: Support prepend-path build option
- Date: Tue, 27 Jul 2021 22:54:19 +0000 (UTC)
commit 068a4ba41ad144ff0c691f3ac9cd9ca2744c0b42
Author: James Westman <james jwestman net>
Date: Tue Jul 27 12:12:39 2021 -0500
flatpak: Support prepend-path build option
append-path was supported, but not prepend-path. Builder's own manifest now
uses prepend-path, so this is necessary for Builder to build itself.
src/libide/foundry/ide-config.c | 48 ++++++++++++++++++++++++++
src/libide/foundry/ide-config.h | 5 +++
src/libide/threading/ide-subprocess-launcher.c | 24 +++++++++++++
src/libide/threading/ide-subprocess-launcher.h | 3 ++
src/plugins/flatpak/gbp-flatpak-manifest.c | 4 +++
5 files changed, 84 insertions(+)
---
diff --git a/src/libide/foundry/ide-config.c b/src/libide/foundry/ide-config.c
index 46c8123ca..4ffacd21e 100644
--- a/src/libide/foundry/ide-config.c
+++ b/src/libide/foundry/ide-config.c
@@ -46,6 +46,7 @@ typedef struct
gchar *run_opts;
gchar *runtime_id;
gchar *toolchain_id;
+ gchar *prepend_path;
gchar *append_path;
GFile *build_commands_dir;
@@ -79,6 +80,7 @@ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (IdeConfig, ide_config, IDE_TYPE_OBJECT)
enum {
PROP_0,
+ PROP_PREPEND_PATH,
PROP_APPEND_PATH,
PROP_APP_ID,
PROP_BUILD_COMMANDS,
@@ -322,6 +324,8 @@ ide_config_finalize (GObject *object)
g_clear_pointer (&priv->runtime_id, g_free);
g_clear_pointer (&priv->app_id, g_free);
g_clear_pointer (&priv->toolchain_id, g_free);
+ g_clear_pointer (&priv->prepend_path, g_free);
+ g_clear_pointer (&priv->append_path, g_free);
G_OBJECT_CLASS (ide_config_parent_class)->finalize (object);
}
@@ -408,6 +412,10 @@ ide_config_get_property (GObject *object,
g_value_set_string (value, ide_config_get_app_id (self));
break;
+ case PROP_PREPEND_PATH:
+ g_value_set_string (value, ide_config_get_prepend_path (self));
+ break;
+
case PROP_APPEND_PATH:
g_value_set_string (value, ide_config_get_append_path (self));
break;
@@ -495,6 +503,10 @@ ide_config_set_property (GObject *object,
ide_config_set_app_id (self, g_value_get_string (value));
break;
+ case PROP_PREPEND_PATH:
+ ide_config_set_prepend_path (self, g_value_get_string (value));
+ break;
+
case PROP_APPEND_PATH:
ide_config_set_append_path (self, g_value_get_string (value));
break;
@@ -523,6 +535,13 @@ ide_config_class_init (IdeConfigClass *klass)
klass->get_runtime = ide_config_real_get_runtime;
klass->set_runtime = ide_config_real_set_runtime;
+ properties [PROP_PREPEND_PATH] =
+ g_param_spec_string ("prepend-path",
+ "Prepend Path",
+ "Prepend to PATH environment variable",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
properties [PROP_APPEND_PATH] =
g_param_spec_string ("append-path",
"Append Path",
@@ -1673,6 +1692,32 @@ ide_config_set_run_opts (IdeConfig *self,
}
}
+const gchar *
+ide_config_get_prepend_path (IdeConfig *self)
+{
+ IdeConfigPrivate *priv = ide_config_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_CONFIG (self), NULL);
+
+ return priv->prepend_path;
+}
+
+void
+ide_config_set_prepend_path (IdeConfig *self,
+ const gchar *prepend_path)
+{
+ IdeConfigPrivate *priv = ide_config_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_CONFIG (self));
+
+ if (priv->prepend_path != prepend_path)
+ {
+ g_free (priv->prepend_path);
+ priv->prepend_path = g_strdup (prepend_path);
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_PREPEND_PATH]);
+ }
+}
+
const gchar *
ide_config_get_append_path (IdeConfig *self)
{
@@ -1708,6 +1753,9 @@ ide_config_apply_path (IdeConfig *self,
g_return_if_fail (IDE_IS_CONFIG (self));
g_return_if_fail (IDE_IS_SUBPROCESS_LAUNCHER (launcher));
+ if (priv->prepend_path != NULL)
+ ide_subprocess_launcher_prepend_path (launcher, priv->prepend_path);
+
if (priv->append_path != NULL)
ide_subprocess_launcher_append_path (launcher, priv->append_path);
}
diff --git a/src/libide/foundry/ide-config.h b/src/libide/foundry/ide-config.h
index da56feba2..66f2b175d 100644
--- a/src/libide/foundry/ide-config.h
+++ b/src/libide/foundry/ide-config.h
@@ -58,6 +58,11 @@ struct _IdeConfigClass
gpointer _reserved[15];
};
+IDE_AVAILABLE_IN_41
+const gchar *ide_config_get_prepend_path (IdeConfig *self);
+IDE_AVAILABLE_IN_41
+void ide_config_set_prepend_path (IdeConfig *self,
+ const gchar *prepend_path);
IDE_AVAILABLE_IN_3_32
const gchar *ide_config_get_append_path (IdeConfig *self);
IDE_AVAILABLE_IN_3_32
diff --git a/src/libide/threading/ide-subprocess-launcher.c b/src/libide/threading/ide-subprocess-launcher.c
index 6e4ed714e..0057d3b01 100644
--- a/src/libide/threading/ide-subprocess-launcher.c
+++ b/src/libide/threading/ide-subprocess-launcher.c
@@ -1080,6 +1080,30 @@ ide_subprocess_launcher_set_stdout_file_path (IdeSubprocessLauncher *self,
}
}
+void
+ide_subprocess_launcher_prepend_path (IdeSubprocessLauncher *self,
+ const gchar *path)
+{
+ const gchar *old_path;
+
+ g_return_if_fail (IDE_IS_SUBPROCESS_LAUNCHER (self));
+
+ if (path == NULL)
+ return;
+
+ old_path = ide_subprocess_launcher_getenv (self, "PATH");
+
+ if (old_path != NULL)
+ {
+ g_autofree gchar *new_path = g_strdup_printf ("%s:%s", path, old_path);
+ ide_subprocess_launcher_setenv (self, "PATH", new_path, TRUE);
+ }
+ else
+ {
+ ide_subprocess_launcher_setenv (self, "PATH", path, TRUE);
+ }
+}
+
void
ide_subprocess_launcher_append_path (IdeSubprocessLauncher *self,
const gchar *path)
diff --git a/src/libide/threading/ide-subprocess-launcher.h b/src/libide/threading/ide-subprocess-launcher.h
index e1b42a57a..d674aaf1b 100644
--- a/src/libide/threading/ide-subprocess-launcher.h
+++ b/src/libide/threading/ide-subprocess-launcher.h
@@ -66,6 +66,9 @@ gboolean ide_subprocess_launcher_get_run_on_host (IdeSubproce
IDE_AVAILABLE_IN_3_32
void ide_subprocess_launcher_set_run_on_host (IdeSubprocessLauncher *self,
gboolean run_on_host);
+IDE_AVAILABLE_IN_41
+void ide_subprocess_launcher_prepend_path (IdeSubprocessLauncher *self,
+ const gchar *prepend_path);
IDE_AVAILABLE_IN_3_32
void ide_subprocess_launcher_append_path (IdeSubprocessLauncher *self,
const gchar *append_path);
diff --git a/src/plugins/flatpak/gbp-flatpak-manifest.c b/src/plugins/flatpak/gbp-flatpak-manifest.c
index 07670e361..ba0750eb6 100644
--- a/src/plugins/flatpak/gbp-flatpak-manifest.c
+++ b/src/plugins/flatpak/gbp-flatpak-manifest.c
@@ -246,6 +246,10 @@ discover_environ (GbpFlatpakManifest *self,
(str = json_object_get_string_member (build_options, "cxxflags")))
ide_environment_setenv (env, "CXXFLAGS", str);
+ if (json_object_has_member (build_options, "prepend-path") &&
+ (str = json_object_get_string_member (build_options, "prepend-path")))
+ ide_config_set_prepend_path (IDE_CONFIG (self), str);
+
if (json_object_has_member (build_options, "append-path") &&
(str = json_object_get_string_member (build_options, "append-path")))
ide_config_set_append_path (IDE_CONFIG (self), str);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]