[gnome-builder] runner: add launcher creation vfuncs
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] runner: add launcher creation vfuncs
- Date: Tue, 21 Feb 2017 07:46:34 +0000 (UTC)
commit 486906a5b48dd7c83ee124f1b8de664e68837f70
Author: Christian Hergert <chergert redhat com>
Date: Mon Feb 20 23:44:06 2017 -0800
runner: add launcher creation vfuncs
This allows subclasses to hook up custom launchers without having to
duplicate all of the work to spawn the subprocesses.
libide/runner/ide-runner.c | 30 +++++++++++++++++++++++++++---
libide/runner/ide-runner.h | 38 +++++++++++++++++++++++++-------------
2 files changed, 52 insertions(+), 16 deletions(-)
---
diff --git a/libide/runner/ide-runner.c b/libide/runner/ide-runner.c
index 86c4c55..df91c7e 100644
--- a/libide/runner/ide-runner.c
+++ b/libide/runner/ide-runner.c
@@ -40,6 +40,8 @@ typedef struct
PeasExtensionSet *addins;
IdeEnvironment *env;
+ GArray *fd_mapping;
+
GQueue argv;
GSubprocessFlags flags;
@@ -165,6 +167,24 @@ ide_runner_run_wait_cb (GObject *object,
IDE_EXIT;
}
+static IdeSubprocessLauncher *
+ide_runner_real_create_launcher (IdeRunner *self)
+{
+ IdeConfigurationManager *config_manager;
+ IdeConfiguration *config;
+ IdeContext *context;
+ IdeRuntime *runtime;
+
+ g_assert (IDE_IS_RUNNER (self));
+
+ 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);
+
+ return ide_runtime_create_launcher (runtime, NULL);
+}
+
static void
ide_runner_real_run_async (IdeRunner *self,
GCancellable *cancellable,
@@ -195,9 +215,8 @@ ide_runner_real_run_async (IdeRunner *self,
config = ide_configuration_manager_get_current (config_manager);
runtime = ide_configuration_get_runtime (config);
-
if (runtime != NULL)
- launcher = ide_runtime_create_launcher (runtime, NULL);
+ launcher = IDE_RUNNER_GET_CLASS (self)->create_launcher (self);
if (launcher == NULL)
launcher = ide_subprocess_launcher_new (0);
@@ -251,7 +270,7 @@ ide_runner_real_run_async (IdeRunner *self,
/*
* Push all of our configured arguments in order.
*/
- for (GList *iter = priv->argv.head; iter != NULL; iter = iter->next)
+ for (const GList *iter = priv->argv.head; iter != NULL; iter = iter->next)
ide_subprocess_launcher_push_argv (launcher, iter->data);
/*
@@ -260,6 +279,10 @@ ide_runner_real_run_async (IdeRunner *self,
*/
ide_subprocess_launcher_set_cwd (launcher, g_get_home_dir ());
+ /* Give the runner a final chance to mutate the launcher */
+ if (IDE_RUNNER_GET_CLASS (self)->fixup_launcher)
+ IDE_RUNNER_GET_CLASS (self)->fixup_launcher (self, launcher);
+
subprocess = ide_subprocess_launcher_spawn (launcher, cancellable, &error);
g_assert (subprocess == NULL || IDE_IS_SUBPROCESS (subprocess));
@@ -489,6 +512,7 @@ ide_runner_class_init (IdeRunnerClass *klass)
klass->run_async = ide_runner_real_run_async;
klass->run_finish = ide_runner_real_run_finish;
klass->set_tty = ide_runner_real_set_tty;
+ klass->create_launcher = ide_runner_real_create_launcher;
properties [PROP_ARGV] =
g_param_spec_boxed ("argv",
diff --git a/libide/runner/ide-runner.h b/libide/runner/ide-runner.h
index 8fa3e1b..17ad1ea 100644
--- a/libide/runner/ide-runner.h
+++ b/libide/runner/ide-runner.h
@@ -34,19 +34,31 @@ struct _IdeRunnerClass
{
IdeObjectClass parent;
- void (*force_quit) (IdeRunner *self);
- GInputStream *(*get_stdin) (IdeRunner *self);
- GOutputStream *(*get_stdout) (IdeRunner *self);
- GOutputStream *(*get_stderr) (IdeRunner *self);
- void (*run_async) (IdeRunner *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gboolean (*run_finish) (IdeRunner *self,
- GAsyncResult *result,
- GError **error);
- void (*set_tty) (IdeRunner *self,
- int tty_fd);
+ void (*force_quit) (IdeRunner *self);
+ GInputStream *(*get_stdin) (IdeRunner *self);
+ GOutputStream *(*get_stdout) (IdeRunner *self);
+ GOutputStream *(*get_stderr) (IdeRunner *self);
+ void (*run_async) (IdeRunner *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ gboolean (*run_finish) (IdeRunner *self,
+ GAsyncResult *result,
+ GError **error);
+ void (*set_tty) (IdeRunner *self,
+ int tty_fd);
+ IdeSubprocessLauncher *(*create_launcher) (IdeRunner *self);
+ void (*fixup_launcher) (IdeRunner *self,
+ IdeSubprocessLauncher *launcher);
+
+ gpointer _reserved1;
+ gpointer _reserved2;
+ gpointer _reserved3;
+ gpointer _reserved4;
+ gpointer _reserved5;
+ gpointer _reserved6;
+ gpointer _reserved7;
+ gpointer _reserved8;
};
IdeRunner *ide_runner_new (IdeContext *context);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]