[gnome-builder/wip/gtk4-port: 1718/1774] libide/foundry: add run command helper
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 1718/1774] libide/foundry: add run command helper
- Date: Mon, 11 Jul 2022 22:31:55 +0000 (UTC)
commit 3f5541751e7345ab9c1a63059974ee39a2ac191b
Author: Christian Hergert <chergert redhat com>
Date: Tue Jun 28 15:01:13 2022 -0700
libide/foundry: add run command helper
There are plenty of cases going forward were we'll want to simply convert
a run command into a run context that will execute within the pipeline.
src/libide/foundry/ide-pipeline.c | 37 +++++++++++++++++++++++++++++++++++++
src/libide/foundry/ide-pipeline.h | 3 +++
2 files changed, 40 insertions(+)
---
diff --git a/src/libide/foundry/ide-pipeline.c b/src/libide/foundry/ide-pipeline.c
index 5df65079f..693b12f3a 100644
--- a/src/libide/foundry/ide-pipeline.c
+++ b/src/libide/foundry/ide-pipeline.c
@@ -50,6 +50,7 @@
#include "ide-foundry-enums.h"
#include "ide-local-deploy-strategy.h"
#include "ide-local-device.h"
+#include "ide-run-command.h"
#include "ide-run-context.h"
#include "ide-run-manager-private.h"
#include "ide-runtime.h"
@@ -4389,3 +4390,39 @@ ide_pipeline_prepare_run_context (IdePipeline *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));
}
+
+/**
+ * ide_pipeline_create_run_context:
+ * @self: a #IdePipeline
+ * @run_command: an #IdeRunCommand
+ *
+ * Creates a new #IdeRunContext to run @run_command.
+ *
+ * This helper is generally meant to be used by pipeline stages to create
+ * a run context that will execute within the pipeline to run the command
+ * described in @run_command.
+ *
+ * The run context is first prepared using ide_pipeline_prepare_run_context()
+ * after which the run command's ide_run_command_prepare_to_run() is used.
+ *
+ * Returns: (transfer full): an #IdeRunContext
+ */
+IdeRunContext *
+ide_pipeline_create_run_context (IdePipeline *self,
+ IdeRunCommand *run_command)
+{
+ g_autoptr(IdeRunContext) run_context = NULL;
+ IdeContext *context;
+
+ g_return_val_if_fail (IDE_IS_PIPELINE (self), NULL);
+ g_return_val_if_fail (IDE_IS_RUN_COMMAND (run_command), NULL);
+
+ context = ide_object_get_context (IDE_OBJECT (self));
+ g_return_val_if_fail (IDE_IS_CONTEXT (context), NULL);
+
+ run_context = ide_run_context_new ();
+ ide_pipeline_prepare_run_context (self, run_context);
+ ide_run_command_prepare_to_run (run_command, run_context, context);
+
+ return g_steal_pointer (&run_context);
+}
diff --git a/src/libide/foundry/ide-pipeline.h b/src/libide/foundry/ide-pipeline.h
index 7adc3aa16..05a3ead93 100644
--- a/src/libide/foundry/ide-pipeline.h
+++ b/src/libide/foundry/ide-pipeline.h
@@ -92,6 +92,9 @@ IDE_AVAILABLE_IN_ALL
IdeSubprocessLauncher *ide_pipeline_create_launcher (IdePipeline *self,
GError **error);
IDE_AVAILABLE_IN_ALL
+IdeRunContext *ide_pipeline_create_run_context (IdePipeline *self,
+ IdeRunCommand *run_command);
+IDE_AVAILABLE_IN_ALL
void ide_pipeline_prepare_run_context (IdePipeline *self,
IdeRunContext *run_context);
IDE_AVAILABLE_IN_ALL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]