[gnome-builder/gnome-builder-43] plugins/meson: prioritize default run-commands by directory



commit 8873eb0fd19427bf69466987dfee8dc1cbaacea3
Author: Christian Hergert <chergert redhat com>
Date:   Sat Sep 24 13:50:38 2022 -0700

    plugins/meson: prioritize default run-commands by directory
    
    This makes sure things like $prefix/bin/exec get preferred over things like
    $prefix/libexec/exec.

 src/plugins/meson/gbp-meson-introspection.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/src/plugins/meson/gbp-meson-introspection.c b/src/plugins/meson/gbp-meson-introspection.c
index 212b1c22f..63a556cdc 100644
--- a/src/plugins/meson/gbp-meson-introspection.c
+++ b/src/plugins/meson/gbp-meson-introspection.c
@@ -327,6 +327,8 @@ gbp_meson_introspection_load_targets (GbpMesonIntrospection *self,
           if (filename != NULL && filename[0] != NULL)
             {
               g_autoptr(IdeRunCommand) run_command = ide_run_command_new ();
+              g_auto(GStrv) install_filename = NULL;
+              g_autofree char *install_dir = NULL;
 
               ide_run_command_set_kind (run_command, IDE_RUN_COMMAND_KIND_UTILITY);
               ide_run_command_set_id (run_command, id);
@@ -334,6 +336,16 @@ gbp_meson_introspection_load_targets (GbpMesonIntrospection *self,
               ide_run_command_set_argv (run_command, IDE_STRV_INIT (filename[0]));
               ide_run_command_set_can_default (run_command, installed);
 
+              /* Deprioritize any executable not installed to $prefix/bin/ */
+              if (get_strv_member (obj, "install_filename", &install_filename) &&
+                  install_filename != NULL &&
+                  install_filename[0] != NULL &&
+                  (install_dir = g_path_get_dirname (install_filename[0])) &&
+                  g_str_has_suffix (install_dir, "/bin"))
+                ide_run_command_set_priority (run_command, 0);
+              else
+                ide_run_command_set_priority (run_command, 1000);
+
               g_list_store_append (self->run_commands, run_command);
             }
         }


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