mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-05 10:17:00 +02:00
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. https://bugzilla.gnome.org/show_bug.cgi?id=794285
This commit is contained in:
parent
c5c3fa83c9
commit
b4117b8d88
@ -297,7 +297,31 @@ end_element (GMarkupParseContext *context,
|
||||
}
|
||||
g_strfreev (options);
|
||||
|
||||
if (xml_stripblanks && xmllint != NULL)
|
||||
if (xml_stripblanks)
|
||||
{
|
||||
/* This is not fatal: pretty-printed XML is still valid XML */
|
||||
if (xmllint == NULL)
|
||||
{
|
||||
static gboolean xmllint_warned = FALSE;
|
||||
|
||||
if (!xmllint_warned)
|
||||
{
|
||||
/* Translators: the first %s is a gresource XML attribute,
|
||||
* the second %s is an environment variable, and the third
|
||||
* %s is a command line tool
|
||||
*/
|
||||
char *warn = g_strdup_printf (_("%s preprocessing requested, but %s is not set, and %s is not in PATH"),
|
||||
"xml-stripblanks",
|
||||
"XMLLINT",
|
||||
"xmllint");
|
||||
g_printerr ("%s\n", warn);
|
||||
g_free (warn);
|
||||
|
||||
/* Only warn once */
|
||||
xmllint_warned = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GSubprocess *proc;
|
||||
int fd;
|
||||
@ -326,8 +350,35 @@ end_element (GMarkupParseContext *context,
|
||||
|
||||
real_file = g_strdup (tmp_file);
|
||||
}
|
||||
}
|
||||
|
||||
if (json_stripblanks && jsonformat != NULL)
|
||||
if (json_stripblanks)
|
||||
{
|
||||
/* As above, this is not fatal: pretty-printed JSON is still
|
||||
* valid JSON
|
||||
*/
|
||||
if (jsonformat == NULL)
|
||||
{
|
||||
static gboolean jsonformat_warned = FALSE;
|
||||
|
||||
if (!jsonformat_warned)
|
||||
{
|
||||
/* Translators: the first %s is a gresource XML attribute,
|
||||
* the second %s is an environment variable, and the third
|
||||
* %s is a command line tool
|
||||
*/
|
||||
char *warn = g_strdup_printf (_("%s preprocessing requested, but %s is not set, and %s is not in PATH"),
|
||||
"json-stripblanks",
|
||||
"JSON_GLIB_FORMAT",
|
||||
"json-glib-format");
|
||||
g_printerr ("%s\n", warn);
|
||||
g_free (warn);
|
||||
|
||||
/* Only warn once */
|
||||
jsonformat_warned = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GSubprocess *proc;
|
||||
int fd;
|
||||
@ -356,17 +407,27 @@ end_element (GMarkupParseContext *context,
|
||||
|
||||
real_file = g_strdup (tmp_file);
|
||||
}
|
||||
}
|
||||
|
||||
if (to_pixdata)
|
||||
{
|
||||
GSubprocess *proc;
|
||||
int fd;
|
||||
|
||||
/* This is a fatal error: if to-pixdata is used it means that
|
||||
* the code loading the GResource expects a specific data format
|
||||
*/
|
||||
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");
|
||||
/* Translators: the first %s is a gresource XML attribute,
|
||||
* the second %s is an environment variable, and the third
|
||||
* %s is a command line tool
|
||||
*/
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
_("%s preprocessing requested, but %s is not set, and %s is not in PATH"),
|
||||
"to-pixdata",
|
||||
"GDK_PIXBUF_PIXDATA",
|
||||
"gdk-pixbuf-pixdata");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -744,14 +805,10 @@ main (int argc, char **argv)
|
||||
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");
|
||||
|
||||
jsonformat = g_strdup (g_getenv ("JSON_GLIB_FORMAT"));
|
||||
if (jsonformat == NULL)
|
||||
jsonformat = g_find_program_in_path ("json-glib-format");
|
||||
if (jsonformat == NULL)
|
||||
g_printerr ("JSON_GLIB_FORMAT not set and json-glib-format not found in path; skipping json pre-processing.\n");
|
||||
|
||||
gdk_pixbuf_pixdata = g_strdup (g_getenv ("GDK_PIXBUF_PIXDATA"));
|
||||
if (gdk_pixbuf_pixdata == NULL)
|
||||
|
Loading…
x
Reference in New Issue
Block a user