[gnome-builder/wip/gtk4-port: 1611/1774] lbide/foundry: separate build/run preparation for run context




commit 40cb96ec6b850e05d70fc578a0b54c4059ca08d2
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jun 22 17:04:47 2022 -0700

    lbide/foundry: separate build/run preparation for run context
    
    These have different requirements and may not need to share the same
    infrastructure to apply translations.
    
    This allows the pipeline to use the proper setup as well.

 src/libide/foundry/ide-deploy-strategy.c        |  2 +-
 src/libide/foundry/ide-pipeline.c               |  3 +-
 src/libide/foundry/ide-runtime.c                | 46 +++++++++++++++++++++----
 src/libide/foundry/ide-runtime.h                |  9 +++--
 src/plugins/flatpak/gbp-flatpak-runtime.c       |  6 ++--
 src/plugins/jhbuild/gbp-jhbuild-runtime.c       |  6 ++--
 src/plugins/podman/gbp-podman-runtime.c         |  6 ++--
 src/plugins/shellcmd/gbp-shellcmd-run-command.c |  2 +-
 8 files changed, 59 insertions(+), 21 deletions(-)
---
diff --git a/src/libide/foundry/ide-deploy-strategy.c b/src/libide/foundry/ide-deploy-strategy.c
index ac1de76c5..7b73b8d81 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_run_context (runtime, run_context);
+    ide_runtime_prepare_to_run (runtime, run_context);
   else
     g_return_if_reached ();
 
diff --git a/src/libide/foundry/ide-pipeline.c b/src/libide/foundry/ide-pipeline.c
index 87da08715..a25bd8736 100644
--- a/src/libide/foundry/ide-pipeline.c
+++ b/src/libide/foundry/ide-pipeline.c
@@ -4368,8 +4368,7 @@ ide_pipeline_prepare_run_context (IdePipeline   *self,
       return;
     }
 
-  /* TODO: setup run context for building instead of running */
-  ide_runtime_prepare_run_context (runtime, run_context);
+  ide_runtime_prepare_to_build (runtime, 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 6e23d61e1..310f571ea 100644
--- a/src/libide/foundry/ide-runtime.c
+++ b/src/libide/foundry/ide-runtime.c
@@ -858,29 +858,63 @@ ide_runtime_supports_toolchain (IdeRuntime   *self,
 }
 
 /**
- * ide_runtime_prepare_run_context:
+ * ide_runtime_prepare_to_run:
  * @self: a #IdeRuntime
  * @run_context: an #IdeRunContext
  *
- * Prepares a run context to run within the runtime.
+ * Prepares a run context to run an application.
  *
  * The virtual function implementation should add to the run context anything
  * necessary to be able to run within the runtime.
  *
  * That might include pushing a new layer so that the command will run within
  * a subcommand such as "flatpak", "jhbuild", or "podman".
+ *
+ * This is meant to be able to run applications, so additional work is expected
+ * of runtimes to ensure access to things like graphical displays.
+ */
+void
+ide_runtime_prepare_to_run (IdeRuntime    *self,
+                            IdeRunContext *run_context)
+{
+  IDE_ENTRY;
+
+  g_return_if_fail (IDE_IS_RUNTIME (self));
+  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);
+
+  IDE_EXIT;
+}
+
+/**
+ * ide_runtime_prepare_to_build:
+ * @self: a #IdeRuntime
+ * @run_context: an #IdeRunContext
+ *
+ * Prepares a run context for running a build command.
+ *
+ * The virtual function implementation should add to the run context anything
+ * necessary to be able to run within the runtime.
+ *
+ * That might include pushing a new layer so that the command will run within
+ * a subcommand such as "flatpak", "jhbuild", or "podman".
+ *
+ * This is meant to be able to run a build command, so it may not require
+ * access to some features like network or graphical displays.
  */
 void
-ide_runtime_prepare_run_context (IdeRuntime    *self,
-                                 IdeRunContext *run_context)
+ide_runtime_prepare_to_build (IdeRuntime    *self,
+                              IdeRunContext *run_context)
 {
   IDE_ENTRY;
 
   g_return_if_fail (IDE_IS_RUNTIME (self));
   g_return_if_fail (IDE_IS_RUN_CONTEXT (run_context));
 
-  if (IDE_RUNTIME_GET_CLASS (self)->prepare_run_context)
-    IDE_RUNTIME_GET_CLASS (self)->prepare_run_context (self, run_context);
+  if (IDE_RUNTIME_GET_CLASS (self)->prepare_to_build)
+    IDE_RUNTIME_GET_CLASS (self)->prepare_to_build (self, run_context);
 
   IDE_EXIT;
 }
diff --git a/src/libide/foundry/ide-runtime.h b/src/libide/foundry/ide-runtime.h
index 73094f288..bd1b71b92 100644
--- a/src/libide/foundry/ide-runtime.h
+++ b/src/libide/foundry/ide-runtime.h
@@ -56,7 +56,9 @@ struct _IdeRuntimeClass
                                                        GError              **error);
   void                    (*prepare_configuration)    (IdeRuntime           *self,
                                                        IdeConfig            *config);
-  void                    (*prepare_run_context)      (IdeRuntime           *self,
+  void                    (*prepare_to_run)           (IdeRuntime           *self,
+                                                       IdeRunContext        *run_context);
+  void                    (*prepare_to_build)         (IdeRuntime           *self,
                                                        IdeRunContext        *run_context);
   IdeRunner              *(*create_runner)            (IdeRuntime           *self,
                                                        IdeBuildTarget       *build_target);
@@ -81,7 +83,10 @@ IDE_AVAILABLE_IN_ALL
 IdeSubprocessLauncher  *ide_runtime_create_launcher          (IdeRuntime      *self,
                                                               GError         **error);
 IDE_AVAILABLE_IN_ALL
-void                    ide_runtime_prepare_run_context      (IdeRuntime      *self,
+void                    ide_runtime_prepare_to_run           (IdeRuntime      *self,
+                                                              IdeRunContext   *run_context);
+IDE_AVAILABLE_IN_ALL
+void                    ide_runtime_prepare_to_build         (IdeRuntime      *self,
                                                               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 f2570cf71..cfc31b01a 100644
--- a/src/plugins/flatpak/gbp-flatpak-runtime.c
+++ b/src/plugins/flatpak/gbp-flatpak-runtime.c
@@ -447,8 +447,8 @@ gbp_flatpak_runtime_handle_run_context_cb (IdeRunContext       *run_context,
 }
 
 static void
-gbp_flatpak_runtime_prepare_run_context (IdeRuntime    *runtime,
-                                         IdeRunContext *run_context)
+gbp_flatpak_runtime_prepare_to_run (IdeRuntime    *runtime,
+                                    IdeRunContext *run_context)
 {
   IDE_ENTRY;
 
@@ -846,7 +846,7 @@ gbp_flatpak_runtime_class_init (GbpFlatpakRuntimeClass *klass)
   runtime_class->create_runner = gbp_flatpak_runtime_create_runner;
   runtime_class->contains_program_in_path = gbp_flatpak_runtime_contains_program_in_path;
   runtime_class->prepare_configuration = gbp_flatpak_runtime_prepare_configuration;
-  runtime_class->prepare_run_context = gbp_flatpak_runtime_prepare_run_context;
+  runtime_class->prepare_to_run = gbp_flatpak_runtime_prepare_to_run;
   runtime_class->translate_file = gbp_flatpak_runtime_translate_file;
   runtime_class->get_system_include_dirs = gbp_flatpak_runtime_get_system_include_dirs;
   runtime_class->get_triplet = gbp_flatpak_runtime_real_get_triplet;
diff --git a/src/plugins/jhbuild/gbp-jhbuild-runtime.c b/src/plugins/jhbuild/gbp-jhbuild-runtime.c
index ab2a2aea2..c3ef4f374 100644
--- a/src/plugins/jhbuild/gbp-jhbuild-runtime.c
+++ b/src/plugins/jhbuild/gbp-jhbuild-runtime.c
@@ -130,8 +130,8 @@ gbp_jhbuild_runtime_run_handler (IdeRunContext       *run_context,
 }
 
 static void
-gbp_jhbuild_runtime_prepare_run_context (IdeRuntime    *runtime,
-                                         IdeRunContext *run_context)
+gbp_jhbuild_runtime_prepare_to_run (IdeRuntime    *runtime,
+                                    IdeRunContext *run_context)
 {
   GbpJhbuildRuntime *self = (GbpJhbuildRuntime *)runtime;
 
@@ -261,7 +261,7 @@ gbp_jhbuild_runtime_class_init (GbpJhbuildRuntimeClass *klass)
   runtime_class->create_launcher = gbp_jhbuild_runtime_create_launcher;
   runtime_class->create_runner = gbp_jhbuild_runtime_create_runner;
   runtime_class->prepare_configuration = gbp_jhbuild_runtime_prepare_configuration;
-  runtime_class->prepare_run_context = gbp_jhbuild_runtime_prepare_run_context;
+  runtime_class->prepare_to_run = gbp_jhbuild_runtime_prepare_to_run;
 
   properties [PROP_EXECUTABLE_PATH] =
     g_param_spec_string ("executable-path", NULL, NULL,
diff --git a/src/plugins/podman/gbp-podman-runtime.c b/src/plugins/podman/gbp-podman-runtime.c
index e3deddb66..616139e68 100644
--- a/src/plugins/podman/gbp-podman-runtime.c
+++ b/src/plugins/podman/gbp-podman-runtime.c
@@ -160,8 +160,8 @@ gbp_podman_runtime_run_handler_cb (IdeRunContext       *run_context,
 }
 
 static void
-gbp_podman_runtime_prepare_run_context (IdeRuntime    *runtime,
-                                        IdeRunContext *run_context)
+gbp_podman_runtime_prepare_to_run (IdeRuntime    *runtime,
+                                   IdeRunContext *run_context)
 {
   IDE_ENTRY;
 
@@ -552,7 +552,7 @@ gbp_podman_runtime_class_init (GbpPodmanRuntimeClass *klass)
 
   runtime_class->create_launcher = gbp_podman_runtime_create_launcher;
   runtime_class->translate_file = gbp_podman_runtime_translate_file;
-  runtime_class->prepare_run_context = gbp_podman_runtime_prepare_run_context;
+  runtime_class->prepare_to_run = gbp_podman_runtime_prepare_to_run;
 }
 
 static void
diff --git a/src/plugins/shellcmd/gbp-shellcmd-run-command.c b/src/plugins/shellcmd/gbp-shellcmd-run-command.c
index ebceadd70..edd22129d 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_run_context (runtime, run_context);
+      ide_runtime_prepare_to_run (runtime, run_context);
       break;
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]