Improve depfile generated by glib-compile-resources

glib-compile-resources --dependency-file= currently generates a depfile
with rules that look like this:

foo.xml: resource1 resource2

This means that if any of the files listed in the GResource manifest
foo.xml change, rebuild foo.xml because foo.xml depends on those files.
This is not useful because the XML manifest is not expected to be a
generated dependency and even if it was, changes to the listed files
would not imply any need to regenerate the manifest. What we really do
need to regenerate is the C source file that is generated by
glib-compile-resources after processing the XML manifest and all the
resource files. That is, the rule should look like this:

foo.c: foo.xml resource1 resource2

as suggested by Hans Ulrich Niedermann in the issue report.

Fixes #2829
This commit is contained in:
Michael Catanzaro 2023-05-31 14:50:21 -05:00
parent 5c50aec060
commit 3e3a0304f7

View File

@ -987,11 +987,15 @@ main (int argc, char **argv)
g_hash_table_iter_init (&iter, files);
dep_string = g_string_new (NULL);
escaped = escape_makefile_string (srcfile);
escaped = escape_makefile_string (target);
g_string_printf (dep_string, "%s:", escaped);
g_free (escaped);
/* First rule: foo.xml: resource1 resource2.. */
escaped = escape_makefile_string (srcfile);
g_string_append_printf (dep_string, " %s", escaped);
g_free (escaped);
/* First rule: foo.c: foo.xml resource1 resource2.. */
while (g_hash_table_iter_next (&iter, &key, &data))
{
file_data = data;