[gnome-builder] makecache: fix replacement of -C <directory>



commit 22fa2e40c9a4c82720eb751574590f800339232a
Author: Christian Hergert <chergert redhat com>
Date:   Fri Feb 24 19:44:34 2017 -0800

    makecache: fix replacement of -C <directory>
    
    This was pretty complex, for no real good reason anymore. It was probably
    due to needing to be relative for when we end up in a different build
    directory (such as flatpak), but we map in all those directories now,
    so we should be okay with using the proper build directory. Meaning we
    can just simply replace the argument after -C.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=771145

 plugins/autotools/ide-makecache.c |   42 ++++++++-----------------------------
 1 files changed, 9 insertions(+), 33 deletions(-)
---
diff --git a/plugins/autotools/ide-makecache.c b/plugins/autotools/ide-makecache.c
index d1b0a4c..68ab174 100644
--- a/plugins/autotools/ide-makecache.c
+++ b/plugins/autotools/ide-makecache.c
@@ -1468,9 +1468,6 @@ ide_makecache_get_build_targets_worker (GTask        *task,
   gchar *line;
   gsize line_len;
   IdeLineReader reader;
-  const gchar * const * partial_argv;
-  guint num_args;
-  gboolean first_subdir = TRUE;
 
   IDE_ENTRY;
 
@@ -1511,9 +1508,8 @@ ide_makecache_get_build_targets_worker (GTask        *task,
 
   ide_subprocess_launcher_push_argv (launcher, self->make_name);
 
-  /* Find the argv index so we can insert arguments on each run */
-  partial_argv = ide_subprocess_launcher_get_argv (launcher);
-  for (num_args = 0; partial_argv[num_args] != NULL; num_args++) { }
+  ide_subprocess_launcher_push_argv (launcher, "-C");
+  ide_subprocess_launcher_push_argv (launcher, "FAKE_BUILD_DIR");
 
   ide_subprocess_launcher_push_argv (launcher, "-f");
   ide_subprocess_launcher_push_argv (launcher, "-");
@@ -1573,35 +1569,15 @@ ide_makecache_get_build_targets_worker (GTask        *task,
        * the same directory as the process.
        */
       makedir = g_ptr_array_index (makedirs, j);
-      rel_path = g_file_get_relative_path (build_dir, makedir);
-      if (rel_path == NULL)
-        {
-          g_autofree gchar *path = NULL;
-          path = g_file_get_path (makedir);
-          ide_subprocess_launcher_set_cwd (launcher, path);
-        }
-      else
+      path = g_file_get_path (makedir);
+      argv = ide_subprocess_launcher_get_argv (launcher);
+
+      for (guint i = 0; argv[i]; i++)
         {
-          if (first_subdir)
-            {
-              ide_subprocess_launcher_insert_argv (launcher, num_args, "-C");
-              ide_subprocess_launcher_insert_argv (launcher, (num_args + 1), rel_path);
-              first_subdir = FALSE;
-            }
-          else
+          if (g_str_equal (argv[i], "-C"))
             {
-              /*
-               * Because the launcher might modify the arguments (as the flatpak one does),
-               * we should recalculate where the subdirectory is in the list.
-               */
-              const gchar * const * current_argv;
-              guint subdir_pos;
-              current_argv = ide_subprocess_launcher_get_argv (launcher);
-              for (subdir_pos = 0;
-                   current_argv[subdir_pos] != NULL &&
-                   g_strcmp0 (current_argv[subdir_pos], "-C") != 0;
-                   subdir_pos++) { }
-              ide_subprocess_launcher_replace_argv (launcher, (subdir_pos + 1), rel_path);
+              ide_subprocess_launcher_replace_argv (launcher, i + 1, path);
+              break;
             }
         }
 


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