[gnome-builder/wip/gtk4-port: 1615/1774] libide/foundry: give pipeline access to runtime
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 1615/1774] libide/foundry: give pipeline access to runtime
- Date: Mon, 11 Jul 2022 22:31:51 +0000 (UTC)
commit ba2e5ded860ca4209f18d495a26f7bb98d85fc0e
Author: Christian Hergert <chergert redhat com>
Date: Wed Jun 22 17:49:12 2022 -0700
libide/foundry: give pipeline access to runtime
The runtime may need information from the build pipeline to be able to
setup the environment for the run context. Rather than having it look that
up from the "manager" objects, give it to the runtime directly to avoid
any chances they get the wrong item back during suprious changes.
src/libide/foundry/ide-deploy-strategy.c | 2 +-
src/libide/foundry/ide-pipeline.c | 2 +-
src/libide/foundry/ide-runtime.c | 42 +++++++++++++++++--
src/libide/foundry/ide-runtime.h | 4 ++
src/plugins/flatpak/gbp-flatpak-runtime.c | 56 ++++++++++++-------------
src/plugins/jhbuild/gbp-jhbuild-runtime.c | 2 +
src/plugins/podman/gbp-podman-runtime.c | 2 +
src/plugins/shellcmd/gbp-shellcmd-run-command.c | 2 +-
8 files changed, 75 insertions(+), 37 deletions(-)
---
diff --git a/src/libide/foundry/ide-deploy-strategy.c b/src/libide/foundry/ide-deploy-strategy.c
index 7b73b8d81..ec9483b32 100644
--- a/src/libide/foundry/ide-deploy-strategy.c
+++ b/src/libide/foundry/ide-deploy-strategy.c
@@ -139,7 +139,7 @@ ide_deploy_strategy_real_prepare_run_context (IdeDeployStrategy *self,
* the pipeline's runtime for how to create a run context.
*/
if ((runtime = ide_pipeline_get_runtime (pipeline)))
- ide_runtime_prepare_to_run (runtime, run_context);
+ ide_runtime_prepare_to_run (runtime, pipeline, run_context);
else
g_return_if_reached ();
diff --git a/src/libide/foundry/ide-pipeline.c b/src/libide/foundry/ide-pipeline.c
index a25bd8736..da05072fe 100644
--- a/src/libide/foundry/ide-pipeline.c
+++ b/src/libide/foundry/ide-pipeline.c
@@ -4368,7 +4368,7 @@ ide_pipeline_prepare_run_context (IdePipeline *self,
return;
}
- ide_runtime_prepare_to_build (runtime, run_context);
+ ide_runtime_prepare_to_build (runtime, self, run_context);
ide_run_context_setenv (run_context, "BUILDDIR", ide_pipeline_get_builddir (self));
ide_run_context_setenv (run_context, "SRCDIR", ide_pipeline_get_srcdir (self));
diff --git a/src/libide/foundry/ide-runtime.c b/src/libide/foundry/ide-runtime.c
index 310f571ea..686764a09 100644
--- a/src/libide/foundry/ide-runtime.c
+++ b/src/libide/foundry/ide-runtime.c
@@ -32,9 +32,11 @@
# include "../terminal/ide-terminal-util.h"
#undef IDE_TERMINAL_INSIDE
+#include "ide-build-manager.h"
#include "ide-build-target.h"
#include "ide-config.h"
#include "ide-config-manager.h"
+#include "ide-pipeline.h"
#include "ide-run-context.h"
#include "ide-runtime.h"
#include "ide-runner.h"
@@ -860,6 +862,7 @@ ide_runtime_supports_toolchain (IdeRuntime *self,
/**
* ide_runtime_prepare_to_run:
* @self: a #IdeRuntime
+ * @pipeline: (nullable): an #IdePipeline or %NULL for the current
* @run_context: an #IdeRunContext
*
* Prepares a run context to run an application.
@@ -875,15 +878,30 @@ ide_runtime_supports_toolchain (IdeRuntime *self,
*/
void
ide_runtime_prepare_to_run (IdeRuntime *self,
+ IdePipeline *pipeline,
IdeRunContext *run_context)
{
IDE_ENTRY;
g_return_if_fail (IDE_IS_RUNTIME (self));
+ g_return_if_fail (!pipeline || IDE_IS_PIPELINE (pipeline));
g_return_if_fail (IDE_IS_RUN_CONTEXT (run_context));
- if (IDE_RUNTIME_GET_CLASS (self)->prepare_to_run)
- IDE_RUNTIME_GET_CLASS (self)->prepare_to_run (self, run_context);
+ if (IDE_RUNTIME_GET_CLASS (self)->prepare_to_run == NULL)
+ IDE_EXIT;
+
+ if (pipeline == NULL)
+ {
+ IdeContext *context = ide_object_get_context (IDE_OBJECT (self));
+ IdeBuildManager *build_manager = ide_build_manager_from_context (context);
+
+ pipeline = ide_build_manager_get_pipeline (build_manager);
+ }
+
+ g_return_if_fail (IDE_IS_PIPELINE (pipeline));
+ g_return_if_fail (ide_pipeline_get_runtime (pipeline) == self);
+
+ IDE_RUNTIME_GET_CLASS (self)->prepare_to_run (self, pipeline, run_context);
IDE_EXIT;
}
@@ -891,6 +909,7 @@ ide_runtime_prepare_to_run (IdeRuntime *self,
/**
* ide_runtime_prepare_to_build:
* @self: a #IdeRuntime
+ * @pipeline: (nullable): an #IdePipeline or %NULL for the current
* @run_context: an #IdeRunContext
*
* Prepares a run context for running a build command.
@@ -906,15 +925,30 @@ ide_runtime_prepare_to_run (IdeRuntime *self,
*/
void
ide_runtime_prepare_to_build (IdeRuntime *self,
+ IdePipeline *pipeline,
IdeRunContext *run_context)
{
IDE_ENTRY;
g_return_if_fail (IDE_IS_RUNTIME (self));
+ g_return_if_fail (!pipeline || IDE_IS_PIPELINE (pipeline));
g_return_if_fail (IDE_IS_RUN_CONTEXT (run_context));
- if (IDE_RUNTIME_GET_CLASS (self)->prepare_to_build)
- IDE_RUNTIME_GET_CLASS (self)->prepare_to_build (self, run_context);
+ if (IDE_RUNTIME_GET_CLASS (self)->prepare_to_build == NULL)
+ IDE_EXIT;
+
+ if (pipeline == NULL)
+ {
+ IdeContext *context = ide_object_get_context (IDE_OBJECT (self));
+ IdeBuildManager *build_manager = ide_build_manager_from_context (context);
+
+ pipeline = ide_build_manager_get_pipeline (build_manager);
+ }
+
+ g_return_if_fail (IDE_IS_PIPELINE (pipeline));
+ g_return_if_fail (ide_pipeline_get_runtime (pipeline) == self);
+
+ IDE_RUNTIME_GET_CLASS (self)->prepare_to_build (self, pipeline, run_context);
IDE_EXIT;
}
diff --git a/src/libide/foundry/ide-runtime.h b/src/libide/foundry/ide-runtime.h
index bd1b71b92..5cd87d644 100644
--- a/src/libide/foundry/ide-runtime.h
+++ b/src/libide/foundry/ide-runtime.h
@@ -57,8 +57,10 @@ struct _IdeRuntimeClass
void (*prepare_configuration) (IdeRuntime *self,
IdeConfig *config);
void (*prepare_to_run) (IdeRuntime *self,
+ IdePipeline *pipeline,
IdeRunContext *run_context);
void (*prepare_to_build) (IdeRuntime *self,
+ IdePipeline *pipeline,
IdeRunContext *run_context);
IdeRunner *(*create_runner) (IdeRuntime *self,
IdeBuildTarget *build_target);
@@ -84,9 +86,11 @@ IdeSubprocessLauncher *ide_runtime_create_launcher (IdeRuntime *s
GError **error);
IDE_AVAILABLE_IN_ALL
void ide_runtime_prepare_to_run (IdeRuntime *self,
+ IdePipeline *pipeline,
IdeRunContext *run_context);
IDE_AVAILABLE_IN_ALL
void ide_runtime_prepare_to_build (IdeRuntime *self,
+ IdePipeline *pipeline,
IdeRunContext *run_context);
IDE_AVAILABLE_IN_ALL
IdeRunner *ide_runtime_create_runner (IdeRuntime *self,
diff --git a/src/plugins/flatpak/gbp-flatpak-runtime.c b/src/plugins/flatpak/gbp-flatpak-runtime.c
index 28d9bc6c9..a57ea29ba 100644
--- a/src/plugins/flatpak/gbp-flatpak-runtime.c
+++ b/src/plugins/flatpak/gbp-flatpak-runtime.c
@@ -342,38 +342,34 @@ gbp_flatpak_runtime_handle_run_context_cb (IdeRunContext *run_context,
gpointer user_data,
GError **error)
{
- GbpFlatpakRuntime *self = user_data;
- IdeConfigManager *config_manager;
+ IdePipeline *pipeline = user_data;
+ GbpFlatpakRuntime *self;
g_autofree char *project_build_dir_arg = NULL;
g_autofree char *project_build_dir = NULL;
g_autofree char *doc_portal_arg = NULL;
g_autofree char *staging_dir = NULL;
- IdeBuildManager *build_manager;
- IdePipeline *pipeline;
const char *app_id;
IdeContext *context;
IdeConfig *config;
IDE_ENTRY;
- g_assert (GBP_IS_FLATPAK_RUNTIME (self));
+ g_assert (IDE_IS_PIPELINE (pipeline));
g_assert (IDE_IS_RUN_CONTEXT (run_context));
g_assert (IDE_IS_UNIX_FD_MAP (unix_fd_map));
+ self = GBP_FLATPAK_RUNTIME (ide_pipeline_get_runtime (pipeline));
+ context = ide_object_get_context (IDE_OBJECT (self));
+
+ g_assert (GBP_IS_FLATPAK_RUNTIME (self));
+ g_assert (IDE_IS_CONTEXT (context));
+
/* Pass through the FD mappings */
if (!ide_run_context_merge_unix_fd_map (run_context, unix_fd_map, error))
return FALSE;
- context = ide_object_get_context (IDE_OBJECT (self));
-
- /* Get the the staging directory for "flatpak build" to use */
- build_manager = ide_build_manager_from_context (context);
- pipeline = ide_build_manager_get_pipeline (build_manager);
staging_dir = gbp_flatpak_get_staging_dir (pipeline);
-
- /* Get the app-id and access to config for finish-args */
- config_manager = ide_config_manager_from_context (context);
- config = ide_config_manager_get_current (config_manager);
+ config = ide_pipeline_get_config (pipeline);
app_id = ide_config_get_app_id (config);
/* Make sure our worker has access to our Builder-specific Flatpak repository */
@@ -448,11 +444,13 @@ gbp_flatpak_runtime_handle_run_context_cb (IdeRunContext *run_context,
static void
gbp_flatpak_runtime_prepare_to_run (IdeRuntime *runtime,
+ IdePipeline *pipeline,
IdeRunContext *run_context)
{
IDE_ENTRY;
g_assert (GBP_IS_FLATPAK_RUNTIME (runtime));
+ g_assert (IDE_IS_PIPELINE (pipeline));
g_assert (IDE_IS_RUN_CONTEXT (run_context));
/* We have to run "flatpak build" from the host */
@@ -461,7 +459,7 @@ gbp_flatpak_runtime_prepare_to_run (IdeRuntime *runtime,
/* Handle the upper layer to rewrite the command using "flatpak build" */
ide_run_context_push (run_context,
gbp_flatpak_runtime_handle_run_context_cb,
- g_object_ref (runtime),
+ g_object_ref (pipeline),
g_object_unref);
IDE_EXIT;
@@ -476,12 +474,10 @@ gbp_flatpak_runtime_handle_build_context_cb (IdeRunContext *run_context,
gpointer user_data,
GError **error)
{
- GbpFlatpakRuntime *self = user_data;
- IdeConfigManager *config_manager;
+ IdePipeline *pipeline = user_data;
+ GbpFlatpakRuntime *self;
g_autofree char *staging_dir = NULL;
g_autofree char *ccache_dir = NULL;
- IdeBuildManager *build_manager;
- IdePipeline *pipeline;
const char *srcdir;
const char *builddir;
IdeContext *context;
@@ -489,26 +485,24 @@ gbp_flatpak_runtime_handle_build_context_cb (IdeRunContext *run_context,
IDE_ENTRY;
- g_assert (GBP_IS_FLATPAK_RUNTIME (self));
+ g_assert (IDE_IS_PIPELINE (pipeline));
g_assert (IDE_IS_RUN_CONTEXT (run_context));
g_assert (IDE_IS_UNIX_FD_MAP (unix_fd_map));
+ self = GBP_FLATPAK_RUNTIME (ide_pipeline_get_runtime (pipeline));
+ context = ide_object_get_context (IDE_OBJECT (self));
+
+ g_assert (GBP_IS_FLATPAK_RUNTIME (self));
+ g_assert (IDE_IS_CONTEXT (context));
+
/* Pass through the FD mappings */
if (!ide_run_context_merge_unix_fd_map (run_context, unix_fd_map, error))
return FALSE;
- context = ide_object_get_context (IDE_OBJECT (self));
-
- /* Get the the staging directory for "flatpak build" to use */
- build_manager = ide_build_manager_from_context (context);
- pipeline = ide_build_manager_get_pipeline (build_manager);
staging_dir = gbp_flatpak_get_staging_dir (pipeline);
srcdir = ide_pipeline_get_srcdir (pipeline);
builddir = ide_pipeline_get_builddir (pipeline);
-
- /* Get the app-id and access to config for finish-args */
- config_manager = ide_config_manager_from_context (context);
- config = ide_config_manager_get_current (config_manager);
+ config = ide_pipeline_get_config (pipeline);
/* Make sure our worker has access to our Builder-specific Flatpak repository */
ide_run_context_setenv (run_context, "FLATPAK_CONFIG_DIR", gbp_flatpak_get_config_dir ());
@@ -578,11 +572,13 @@ gbp_flatpak_runtime_handle_build_context_cb (IdeRunContext *run_context,
static void
gbp_flatpak_runtime_prepare_to_build (IdeRuntime *runtime,
+ IdePipeline *pipeline,
IdeRunContext *run_context)
{
IDE_ENTRY;
g_assert (GBP_IS_FLATPAK_RUNTIME (runtime));
+ g_assert (IDE_IS_PIPELINE (pipeline));
g_assert (IDE_IS_RUN_CONTEXT (run_context));
/* We have to run "flatpak build" from the host */
@@ -591,7 +587,7 @@ gbp_flatpak_runtime_prepare_to_build (IdeRuntime *runtime,
/* Handle the upper layer to rewrite the command using "flatpak build" */
ide_run_context_push (run_context,
gbp_flatpak_runtime_handle_build_context_cb,
- g_object_ref (runtime),
+ g_object_ref (pipeline),
g_object_unref);
IDE_EXIT;
diff --git a/src/plugins/jhbuild/gbp-jhbuild-runtime.c b/src/plugins/jhbuild/gbp-jhbuild-runtime.c
index c9eff6294..aa8519748 100644
--- a/src/plugins/jhbuild/gbp-jhbuild-runtime.c
+++ b/src/plugins/jhbuild/gbp-jhbuild-runtime.c
@@ -131,6 +131,7 @@ gbp_jhbuild_runtime_run_handler (IdeRunContext *run_context,
static void
gbp_jhbuild_runtime_prepare_run_context (IdeRuntime *runtime,
+ IdePipeline *pipeline,
IdeRunContext *run_context)
{
GbpJhbuildRuntime *self = (GbpJhbuildRuntime *)runtime;
@@ -138,6 +139,7 @@ gbp_jhbuild_runtime_prepare_run_context (IdeRuntime *runtime,
IDE_ENTRY;
g_assert (GBP_IS_JHBUILD_RUNTIME (self));
+ g_assert (IDE_IS_PIPELINE (pipeline));
g_assert (IDE_IS_RUN_CONTEXT (run_context));
ide_run_context_push (run_context,
diff --git a/src/plugins/podman/gbp-podman-runtime.c b/src/plugins/podman/gbp-podman-runtime.c
index ebb065930..c826e5ecb 100644
--- a/src/plugins/podman/gbp-podman-runtime.c
+++ b/src/plugins/podman/gbp-podman-runtime.c
@@ -161,11 +161,13 @@ gbp_podman_runtime_run_handler_cb (IdeRunContext *run_context,
static void
gbp_podman_runtime_prepare_run_context (IdeRuntime *runtime,
+ IdePipeline *pipeline,
IdeRunContext *run_context)
{
IDE_ENTRY;
g_assert (GBP_IS_PODMAN_RUNTIME (runtime));
+ g_assert (IDE_IS_PIPELINE (pipeline));
g_assert (IDE_IS_RUN_CONTEXT (run_context));
/* Our commands will need to be run from the host */
diff --git a/src/plugins/shellcmd/gbp-shellcmd-run-command.c b/src/plugins/shellcmd/gbp-shellcmd-run-command.c
index edd22129d..0e4798841 100644
--- a/src/plugins/shellcmd/gbp-shellcmd-run-command.c
+++ b/src/plugins/shellcmd/gbp-shellcmd-run-command.c
@@ -384,7 +384,7 @@ gbp_shellcmd_run_command_create_launcher (GbpShellcmdRunCommand *self,
IdeRuntime *runtime = ide_pipeline_get_runtime (pipeline);
if (runtime == NULL)
goto handle_error;
- ide_runtime_prepare_to_run (runtime, run_context);
+ ide_runtime_prepare_to_run (runtime, pipeline, run_context);
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]