[gnome-builder/wip/gtk4-port] libide/foundry: allow toggling install-before-run



commit e8f424f48910c6d5319ddc5ea9b3e0d4c79969da
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jun 15 22:18:38 2022 -0700

    libide/foundry: allow toggling install-before-run
    
    This allows to disable installing before running the project in some cases.
    We still need to do it once, but eventually that can go away too.

 data/gsettings/org.gnome.builder.project.gschema.xml |  6 ++++++
 src/libide/foundry/ide-run-manager.c                 | 17 +++++++++++++++++
 src/libide/gui/ide-preferences-builtin.c             | 10 ++++++++--
 3 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/data/gsettings/org.gnome.builder.project.gschema.xml 
b/data/gsettings/org.gnome.builder.project.gschema.xml
index 0385faf80..b5f3d0144 100644
--- a/data/gsettings/org.gnome.builder.project.gschema.xml
+++ b/data/gsettings/org.gnome.builder.project.gschema.xml
@@ -8,6 +8,12 @@
       <description>The configuration that has been selected and will be restored the next time the project 
loads.</description>
     </key>
 
+    <key name="install-before-run" type="b">
+      <default>true</default>
+      <summary>Install Project Before Running</summary>
+      <description>Run the pipelines install phase before running the project. Only use this if you know 
what you're doing with your project.</description>
+    </key>
+
     <key name="stop-signal" type="s">
       <choices>
         <choice value="SIGKILL"/>
diff --git a/src/libide/foundry/ide-run-manager.c b/src/libide/foundry/ide-run-manager.c
index ae9ce4ddb..6deba05f3 100644
--- a/src/libide/foundry/ide-run-manager.c
+++ b/src/libide/foundry/ide-run-manager.c
@@ -1006,6 +1006,7 @@ ide_run_manager_do_install_before_run (IdeRunManager *self,
                                        IdeTask       *task)
 {
   g_autoptr(IdeContext) context = NULL;
+  g_autoptr(GSettings) project_settings = NULL;
   IdeBuildManager *build_manager;
   IdeVcsMonitor *monitor;
   guint64 sequence = 0;
@@ -1019,6 +1020,7 @@ ide_run_manager_do_install_before_run (IdeRunManager *self,
   context = ide_object_ref_context (IDE_OBJECT (self));
   build_manager = ide_build_manager_from_context (context);
   monitor = ide_vcs_monitor_from_context (context);
+  project_settings = ide_context_ref_project_settings (context);
 
   /*
    * First we need to make sure the target is up to date and installed
@@ -1037,6 +1039,21 @@ ide_run_manager_do_install_before_run (IdeRunManager *self,
   if (monitor != NULL)
     sequence = ide_vcs_monitor_get_sequence (monitor);
 
+  /* If the user requests that we don't do install before running, then they probably
+   * have a work flow that allows them to do that. Just skip build/install and try
+   * to run it directly instead. We do need to do it once however to get the
+   * current build target (although that may change soon).
+   */
+  if (self->build_target != NULL &&
+      !g_settings_get_boolean (project_settings, "install-before-run"))
+    {
+      g_debug ("Skipping install phase as requested in project settings");
+      ide_run_manager_update_action_enabled (self);
+      ide_task_set_task_data (task, g_object_ref (self->build_target), g_object_unref);
+      do_run_async (self, task);
+      IDE_EXIT;
+    }
+
   /*
    * If we detect that nothing has changed in the project directory since the
    * last time we ran, we can avoid installing the project. This will not help
diff --git a/src/libide/gui/ide-preferences-builtin.c b/src/libide/gui/ide-preferences-builtin.c
index 5833fd3a1..5a894aead 100644
--- a/src/libide/gui/ide-preferences-builtin.c
+++ b/src/libide/gui/ide-preferences-builtin.c
@@ -711,7 +711,8 @@ static const IdePreferenceGroupEntry groups[] = {
 };
 
 static const IdePreferenceGroupEntry project_groups[] = {
-  { "application", "start-stop", 0, N_("Starting & Stopping") },
+  { "application", "install",  0, N_("Starting & Stopping") },
+  { "application", "stop",    10 },
 };
 
 static const IdePreferenceItemEntry items[] = {
@@ -765,7 +766,12 @@ static const IdePreferenceItemEntry items[] = {
 };
 
 static const IdePreferenceItemEntry project_items[] = {
-  { "application", "start-stop", "stop-signal", 0, ide_preferences_window_combo,
+  { "application", "install", "install-before-run", 0, ide_preferences_window_toggle,
+    N_("Install Before Running"),
+    N_("Installs the application before running. This is necessary for most projects unless run commands are 
used."),
+    "org.gnome.builder.project", NULL, "install-before-run" },
+
+  { "application", "stop", "stop-signal", 0, ide_preferences_window_combo,
     N_("Stop Signal"),
     N_("Send the signal to the target application when requesting the application stop."),
     "org.gnome.builder.project", NULL, "stop-signal" },


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