After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 794285 - glib-compile-resources should not noisily g_printerr() when xmllint is not found
glib-compile-resources should not noisily g_printerr() when xmllint is not found
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on: 794284
Blocks:
 
 
Reported: 2018-03-13 12:10 UTC by Daniel Boles
Modified: 2018-03-14 15:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Conditionally error if pre-processing tools are not found (3.01 KB, patch)
2018-03-14 10:39 UTC, Emmanuele Bassi (:ebassi)
none Details | Review
Conditionally error if pre-processing tools are not found (3.66 KB, patch)
2018-03-14 12:07 UTC, Emmanuele Bassi (:ebassi)
needs-work Details | Review
Conditionally warn if pre-processing tools are not found (6.68 KB, patch)
2018-03-14 13:56 UTC, Emmanuele Bassi (:ebassi)
none Details | Review
Conditionally warn if pre-processing tools are not found (8.21 KB, patch)
2018-03-14 13:58 UTC, Emmanuele Bassi (:ebassi)
none Details | Review
Conditionally warn if pre-processing tools are not found (8.63 KB, patch)
2018-03-14 14:21 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review

Description Daniel Boles 2018-03-13 12:10:29 UTC
xmllint = g_strdup (g_getenv ("XMLLINT"));
  if (xmllint == NULL)
    xmllint = g_find_program_in_path ("xmllint");
  if (xmllint == NULL)
    g_printerr ("XMLLINT not set and xmllint not found in path; skipping xml preprocessing.\n");

If I'm compiling an app with no XML resources and/or don't care about stripping blanks in them, I shouldn't be bombarded with this message while compiling.

Shouldn't this only be printed if the user explicitly tried to use xmllint, by setting the relevant attribute on a resource component?
Comment 1 Daniel Boles 2018-03-13 12:15:26 UTC
Ideally we could for xml-stripblanks et al. what we do for to-pixdata: only error if an attribute requests the preprocessor:

              if (gdk_pixbuf_pixdata == NULL)
                {
                  g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                                       "to-pixbuf preprocessing requested but GDK_PIXBUF_PIXDATA "
                                       "not set and gdk-pixbuf-pixdata not found in path");
                  goto cleanup;
                }
Comment 2 Emmanuele Bassi (:ebassi) 2018-03-14 10:39:00 UTC
Created attachment 369655 [details] [review]
Conditionally error if pre-processing tools are not found

There's no need to unconditionally print an error message if xmllint or
json-glib-format are not found when running glib-compile-resources is
called; we only need to error out if they are not available when we need
them.
Comment 3 Emmanuele Bassi (:ebassi) 2018-03-14 10:39:48 UTC
Attachment 369655 [details] depends on the patches for bug 794284.
Comment 4 Philip Withnall 2018-03-14 12:05:45 UTC
Review of attachment 369655 [details] [review]:

Sure. Are you planning on marking the strings as translatable in a separate commit?
Comment 5 Emmanuele Bassi (:ebassi) 2018-03-14 12:07:41 UTC
Created attachment 369666 [details] [review]
Conditionally error if pre-processing tools are not found

There's no need to unconditionally print an error message if xmllint or
json-glib-format are not found when running glib-compile-resources is
called; we only need to error out if they are not available when we need
them.
Comment 6 Emmanuele Bassi (:ebassi) 2018-03-14 12:08:14 UTC
Ugh, forgot about that; patch updated.
Comment 7 Emmanuele Bassi (:ebassi) 2018-03-14 12:10:04 UTC
Now that I'm looking at it, though, I see a snag.

Using to-pixdata without gdkpixbuf-to-pixdata is a fatal error because the expected data will be different; not stripping blanks from XML or JSON is not really a fatal error.

This means we should just warn, not error out.
Comment 8 Emmanuele Bassi (:ebassi) 2018-03-14 12:10:28 UTC
Review of attachment 369666 [details] [review]:

Will update with a non-fatal warning.
Comment 9 Philip Withnall 2018-03-14 12:26:58 UTC
Review of attachment 369666 [details] [review]:

::: gio/glib-compile-resources.c
@@ +307,3 @@
+                  g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                                       _("xml-stripblanks preprocessing requested but XMLLINT "
+                                         "not set and xmllint not found in PATH"));

To reduce the number of strings the translators have to translate, you could do this as:

g_strdup_printf (_("%s preprocessing requested but %s not set and %s not found in PATH"), "xml-stripblanks", "XMLLINT", "xmllint")
Comment 10 Emmanuele Bassi (:ebassi) 2018-03-14 13:56:19 UTC
Created attachment 369674 [details] [review]
Conditionally warn if pre-processing tools are not found

There's no need to unconditionally print an error message if xmllint or
json-glib-format are not found when running glib-compile-resources is
called; we only need to warn if they are not available when we need
them. To avoid spamming the build logs, we can also warn once.
Comment 11 Emmanuele Bassi (:ebassi) 2018-03-14 13:58:40 UTC
Created attachment 369675 [details] [review]
Conditionally warn if pre-processing tools are not found

There's no need to unconditionally print an error message if xmllint or
json-glib-format are not found when running glib-compile-resources is
called; we only need to warn if they are not available when we need
them. To avoid spamming the build logs, we can also warn once.
Comment 12 Philip Withnall 2018-03-14 14:15:42 UTC
Review of attachment 369675 [details] [review]:

Looks good to commit with three minor changes.

::: gio/glib-compile-resources.c
@@ +314,3 @@
+                                                    "XMLLINT",
+                                                    "xmllint");
+                      g_printerr ("%s", warn);

Missing \n. Add it here, rather than in the translated string.

@@ +368,3 @@
+                                                    "JSON_GLIB_FORMAT",
+                                                    "json-glib-format");
+                      g_printerr ("%s", warn);

Same here.

@@ +417,3 @@
+                   * %s is a command line tool
+                   */
+                  g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,

Probably wise to add a comment here clarifying why this one is fatal and the other two aren’t.
Comment 13 Emmanuele Bassi (:ebassi) 2018-03-14 14:21:55 UTC
Created attachment 369679 [details] [review]
Conditionally warn if pre-processing tools are not found

There's no need to unconditionally print an error message if xmllint or
json-glib-format are not found when running glib-compile-resources is
called; we only need to warn if they are not available when we need
them. To avoid spamming the build logs, we can also warn once.
Comment 14 Philip Withnall 2018-03-14 15:03:56 UTC
Review of attachment 369679 [details] [review]:

Go go go.
Comment 15 Emmanuele Bassi (:ebassi) 2018-03-14 15:09:08 UTC
Attachment 369679 [details] pushed as b4117b8 - Conditionally warn if pre-processing tools are not found
Comment 16 Daniel Boles 2018-03-14 15:09:31 UTC
Thanks!