[glib/glib-2-48] glib-compile-resources: correct resource compiler dependency for generated files



commit e0c6b8e17aa1623277358bd862bb4bf7778c3583
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Jun 3 23:20:36 2016 -0300

    glib-compile-resources: correct resource compiler dependency for generated files
    
    Don't require that files can be resolved when generating dependencies.
    
    Original patch by Garret Regier.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=673101

 gio/glib-compile-resources.c |   11 +++++++----
 gio/tests/.gitignore         |    1 +
 gio/tests/Makefile.am        |    6 +++++-
 gio/tests/test.gresource.xml |    1 +
 4 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/gio/glib-compile-resources.c b/gio/glib-compile-resources.c
index e1223d6..bc38b56 100644
--- a/gio/glib-compile-resources.c
+++ b/gio/glib-compile-resources.c
@@ -214,7 +214,8 @@ end_element (GMarkupParseContext  *context,
 
   else if (strcmp (element_name, "file") == 0)
     {
-      gchar *file, *real_file;
+      gchar *file;
+      gchar *real_file = NULL;
       gchar *key;
       FileData *data = NULL;
       char *tmp_file = NULL;
@@ -241,7 +242,7 @@ end_element (GMarkupParseContext  *context,
       if (sourcedirs != NULL)
         {
          real_file = find_file (file);
-         if (real_file == NULL)
+         if (real_file == NULL && state->collect_data)
            {
                g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                             _("Failed to locate '%s' in any source directory"), file);
@@ -252,15 +253,17 @@ end_element (GMarkupParseContext  *context,
         {
          gboolean exists;
          exists = g_file_test (file, G_FILE_TEST_EXISTS);
-         if (!exists)
+         if (!exists && state->collect_data)
            {
              g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                           _("Failed to locate '%s' in current directory"), file);
              return;
            }
-         real_file = g_strdup (file);
        }
 
+      if (real_file == NULL)
+        real_file = g_strdup (file);
+
       data = g_new0 (FileData, 1);
       data->filename = g_strdup (real_file);
       if (!state->collect_data)
diff --git a/gio/tests/.gitignore b/gio/tests/.gitignore
index fc7676d..3114790 100644
--- a/gio/tests/.gitignore
+++ b/gio/tests/.gitignore
@@ -126,6 +126,7 @@ socket-service
 socket-server
 srvtarget
 task
+test-generated.txt
 test.gresource
 test.mo
 test_resources.c
diff --git a/gio/tests/Makefile.am b/gio/tests/Makefile.am
index 29c7e47..89730bf 100644
--- a/gio/tests/Makefile.am
+++ b/gio/tests/Makefile.am
@@ -534,6 +534,10 @@ endif
 
 glib_compile_resources=$(top_builddir)/gio/glib-compile-resources
 
+test-generated.txt: test1.txt
+       $(AM_V_GEN) echo "Generated" > $@ && \
+         cat $< >> $@
+
 resources.o: test_resources2.h
 test_resources.c: test2.gresource.xml Makefile $(shell $(glib_compile_resources) --sourcedir=$(srcdir) 
--generate-dependencies $(srcdir)/test2.gresource.xml)
        $(AM_V_GEN) $(glib_compile_resources) --target=$@ --sourcedir=$(srcdir) --generate-source --c-name 
_g_test1 $<
@@ -548,7 +552,7 @@ test.gresource: test.gresource.xml Makefile $(shell $(glib_compile_resources) --
        $(AM_V_GEN) $(glib_compile_resources) --target=$@ --sourcedir=$(srcdir) $<
 
 EXTRA_DIST += test.gresource.xml test1.txt test2.gresource.xml test2.txt test3.gresource.xml test3.txt 
test4.gresource.xml
-CLEANFILES += test_resources.c test_resources2.[ch] plugin_resources.c test.gresource
+CLEANFILES += test-generated.txt test_resources.c test_resources2.[ch] plugin_resources.c test.gresource
 endif # !CROSS_COMPILING
 
 BUILT_SOURCES += giotypefuncs.c
diff --git a/gio/tests/test.gresource.xml b/gio/tests/test.gresource.xml
index 15361e6..dd08aa0 100644
--- a/gio/tests/test.gresource.xml
+++ b/gio/tests/test.gresource.xml
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
   <gresource>
+    <file >test-generated.txt</file>
     <file compressed="true">test1.txt</file>
     <file preprocess="xml-stripblanks">test.gresource.xml</file>
   </gresource>


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