[gnome-builder/wip/mwleeds/dupe-argv] makecache: correctly modify subprocess args for 'make -C'



commit 4ced2f118a8f721ac9498edc3e4843adfc9b86bb
Author: Matthew Leeds <mleeds redhat com>
Date:   Fri Feb 17 16:06:47 2017 -0600

    makecache: correctly modify subprocess args for 'make -C'
    
    The GbpFlatpakSubprocessLauncher modifies the command line arguments
    just before spawning subprocesses, so the position of the subdirectory
    (in "... make -C <subdirectory> ...") changes between the first and
    second spawn from the same launcher. This causes the
    ide_makecache_get_build_targets_worker to replace the wrong argument in
    the list when switching to a different subdirectory. This commit fixes
    the issue by looking for the "-C" argument each time before replacing
    the argument and launching a process.

 plugins/autotools/ide-makecache.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/plugins/autotools/ide-makecache.c b/plugins/autotools/ide-makecache.c
index 44774c5..075d889 100644
--- a/plugins/autotools/ide-makecache.c
+++ b/plugins/autotools/ide-makecache.c
@@ -1590,7 +1590,18 @@ ide_makecache_get_build_targets_worker (GTask        *task,
             }
           else
             {
-              ide_subprocess_launcher_replace_argv (launcher, (num_args + 1), rel_path);
+              /*
+               * 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, rel_path);
             }
         }
 


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