[gnome-builder] log: Print a message when subprocesses are spawned



commit 8e411b5fc6212f3a3dcdc9cfdf6248426e59203b
Author: Matthew Leeds <mleeds redhat com>
Date:   Mon Jul 18 16:04:34 2016 -0400

    log: Print a message when subprocesses are spawned
    
    There are places in the codebase where g_subprocess_launcher_spawn() or
    g_subprocess_new() are called but no message is printed to stdout even
    with tracing enabled. This commit fixes that by adding such a message
    in order to make debugging easier.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769001

 libide/workers/ide-worker-process.c               |   27 ++++++++++---
 plugins/autotools/ide-makecache.c                 |   22 ++++++++++-
 plugins/flatpak/gbp-flatpak-runtime.c             |   40 +++++++++++++------
 plugins/gettext/ide-gettext-diagnostic-provider.c |   44 ++++++++++++++-------
 4 files changed, 99 insertions(+), 34 deletions(-)
---
diff --git a/libide/workers/ide-worker-process.c b/libide/workers/ide-worker-process.c
index e3102a9..e6885c0 100644
--- a/libide/workers/ide-worker-process.c
+++ b/libide/workers/ide-worker-process.c
@@ -118,6 +118,7 @@ ide_worker_process_respawn (IdeWorkerProcess *self)
   g_autofree gchar *dbus_address = NULL;
   g_autoptr(GString) verbosearg = NULL;
   GError *error = NULL;
+  GPtrArray *args;
   gint verbosity;
   gint i;
 
@@ -135,12 +136,26 @@ ide_worker_process_respawn (IdeWorkerProcess *self)
     g_string_append_c (verbosearg, 'v');
 
   launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_NONE);
-  subprocess = g_subprocess_launcher_spawn (launcher, &error,
-                                            self->argv0,  /* gnome-builder */
-                                            type,         /* --type= */
-                                            dbus_address, /* --dbus-addres= */
-                                            verbosity > 0 ? verbosearg->str : NULL,
-                                            NULL);
+  args = g_ptr_array_new ();
+  g_ptr_array_add (args, self->argv0); /* gnome-builder */
+  g_ptr_array_add (args, type); /* --type= */
+  g_ptr_array_add (args, dbus_address); /* --dbus-address= */
+  g_ptr_array_add (args, verbosity > 0 ? verbosearg->str : NULL);
+  g_ptr_array_add (args, NULL);
+
+#ifdef IDE_ENABLE_TRACE
+  {
+    g_autofree gchar *str = NULL;
+    str = g_strjoinv (" ", (gchar **)args->pdata);
+    IDE_TRACE_MSG ("Launching '%s'", str);
+  }
+#endif
+
+  subprocess = g_subprocess_launcher_spawnv (launcher,
+                                             (const gchar * const *)args->pdata,
+                                             &error);
+
+  g_ptr_array_free (args, TRUE);
 
   if (subprocess == NULL)
     {
diff --git a/plugins/autotools/ide-makecache.c b/plugins/autotools/ide-makecache.c
index 9a61c62..01a7c60 100644
--- a/plugins/autotools/ide-makecache.c
+++ b/plugins/autotools/ide-makecache.c
@@ -518,6 +518,7 @@ ide_makecache_new_worker (GTask        *task,
   g_autoptr(GSubprocessLauncher) launcher = NULL;
   g_autoptr(GSubprocess) subprocess = NULL;
   GError *error = NULL;
+  GPtrArray *args;
   int fdcopy;
   int fd;
 
@@ -611,9 +612,28 @@ ide_makecache_new_worker (GTask        *task,
    * Spawn `make -p -n -s` in the directory containing our makefile.
    */
   launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_NONE);
+  args = g_ptr_array_new ();
+  g_ptr_array_add (args, GNU_MAKE_NAME);
+  g_ptr_array_add (args, "-p");
+  g_ptr_array_add (args, "-n");
+  g_ptr_array_add (args, "-s");
+  g_ptr_array_add (args, NULL);
   g_subprocess_launcher_set_cwd (launcher, workdir);
   g_subprocess_launcher_take_stdout_fd (launcher, fdcopy);
-  subprocess = g_subprocess_launcher_spawn (launcher, &error, GNU_MAKE_NAME, "-p", "-n", "-s", NULL);
+
+#ifdef IDE_ENABLE_TRACE
+  {
+    g_autofree gchar *str = NULL;
+    str = g_strjoinv (" ", (gchar **)args->pdata);
+    IDE_TRACE_MSG ("workdir=%s Launching '%s'", workdir, str);
+  }
+#endif
+
+  subprocess = g_subprocess_launcher_spawnv (launcher,
+                                             (const gchar * const *)args->pdata,
+                                             &error);
+
+  g_ptr_array_free (args, TRUE);
   fdcopy = -1;
 
   if (!subprocess)
diff --git a/plugins/flatpak/gbp-flatpak-runtime.c b/plugins/flatpak/gbp-flatpak-runtime.c
index 7ed90c7..9dedb45 100644
--- a/plugins/flatpak/gbp-flatpak-runtime.c
+++ b/plugins/flatpak/gbp-flatpak-runtime.c
@@ -94,6 +94,7 @@ gbp_flatpak_runtime_prebuild_worker (GTask        *task,
   g_autoptr(GSubprocess) subprocess = NULL;
   g_autoptr(GFile) parent = NULL;
   GError *error = NULL;
+  GPtrArray *args;
 
   g_assert (G_IS_TASK (task));
   g_assert (GBP_IS_FLATPAK_RUNTIME (self));
@@ -120,19 +121,32 @@ gbp_flatpak_runtime_prebuild_worker (GTask        *task,
     }
 
   launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_NONE);
-  subprocess = g_subprocess_launcher_spawn (launcher, &error,
-                                            "flatpak",
-                                            "build-init",
-                                            build_path,
-                                            /* XXX: Fake name, probably okay, but
-                                             * can be proper once we get IdeConfiguration
-                                             * in place.
-                                             */
-                                            "org.gnome.Builder.FlatpakApp.Build",
-                                            self->sdk,
-                                            self->platform,
-                                            self->branch,
-                                            NULL);
+  args = g_ptr_array_new ();
+  g_ptr_array_add (args, "flatpak");
+  g_ptr_array_add (args, "build-init");
+  g_ptr_array_add (args, build_path);
+  /* XXX: Fake name, probably okay, but can be proper once we get
+   * IdeConfiguration in place.
+   */
+  g_ptr_array_add (args, "org.gnome.Builder.FlatpakApp.Build");
+  g_ptr_array_add (args, self->sdk);
+  g_ptr_array_add (args, self->platform);
+  g_ptr_array_add (args, self->branch);
+  g_ptr_array_add (args, NULL);
+
+#ifdef IDE_ENABLE_TRACE
+  {
+    g_autofree gchar *str = NULL;
+    str = g_strjoinv (" ", (gchar **)args->pdata);
+    IDE_TRACE_MSG ("Launching '%s'", str);
+  }
+#endif
+
+  subprocess = g_subprocess_launcher_spawnv (launcher,
+                                             (const gchar * const *)args->pdata,
+                                             &error);
+
+  g_ptr_array_free (args, TRUE);
 
   g_task_return_boolean (task, TRUE);
 }
diff --git a/plugins/gettext/ide-gettext-diagnostic-provider.c 
b/plugins/gettext/ide-gettext-diagnostic-provider.c
index 892401e..e757926 100644
--- a/plugins/gettext/ide-gettext-diagnostic-provider.c
+++ b/plugins/gettext/ide-gettext-diagnostic-provider.c
@@ -401,6 +401,7 @@ populate_cache (EggTaskCache  *cache,
   IdeFile *file = (IdeFile *)key;
   GCancellable *cancellable;
   GError *error = NULL;
+  GPtrArray *args;
 
   g_assert (EGG_IS_TASK_CACHE (cache));
   g_assert (IDE_IS_FILE (file));
@@ -438,20 +439,35 @@ populate_cache (EggTaskCache  *cache,
 
   g_assert (temp_path != NULL);
 
-  subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDIN_PIPE
-                                 | G_SUBPROCESS_FLAGS_STDOUT_PIPE
-                                 | G_SUBPROCESS_FLAGS_STDERR_PIPE,
-                                 &error,
-                                 "xgettext",
-                                 "--check=ellipsis-unicode",
-                                 "--check=quote-unicode",
-                                 "--check=space-ellipsis",
-                                 "-k_",
-                                 "-kN_",
-                                 "-L", xgettext_lang,
-                                 "-o" "-",
-                                 temp_path,
-                                 NULL);
+  args = g_ptr_array_new ();
+  g_ptr_array_add (args, "xgettext");
+  g_ptr_array_add (args, "--check=ellipsis-unicode");
+  g_ptr_array_add (args, "--check=quote-unicode");
+  g_ptr_array_add (args, "--check=space-ellipsis");
+  g_ptr_array_add (args, "-k_");
+  g_ptr_array_add (args, "-kN_");
+  g_ptr_array_add (args, "-L");
+  g_ptr_array_add (args, xgettext_lang);
+  g_ptr_array_add (args, "-o");
+  g_ptr_array_add (args, "-");
+  g_ptr_array_add (args, temp_path);
+  g_ptr_array_add (args, NULL);
+
+#ifdef IDE_ENABLE_TRACE
+  {
+    g_autofree gchar *str = NULL;
+    str = g_strjoinv (" ", (gchar **)args->pdata);
+    IDE_TRACE_MSG ("Launching '%s'", str);
+  }
+#endif
+
+  subprocess = g_subprocess_newv ((const gchar * const *)args->pdata,
+                                  G_SUBPROCESS_FLAGS_STDIN_PIPE
+                                  | G_SUBPROCESS_FLAGS_STDOUT_PIPE
+                                  | G_SUBPROCESS_FLAGS_STDERR_PIPE,
+                                  &error);
+
+  g_ptr_array_free (args, TRUE);
 
   if (subprocess == NULL)
     {


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