glib-compile-resources: Add --generate-phony-targets flag

This includes phony targets for each dependency in the the generated
dependency file which allows building with `ninja` which doesn't like
the phony targets[1] but also allows silencing `make` errors similar to
gcc's -MP option.

[1] - https://github.com/ninja-build/ninja/issues/1184

https://bugzilla.gnome.org/show_bug.cgi?id=774368
This commit is contained in:
Patrick Griffis 2016-11-15 08:34:31 -05:00
parent 437474318f
commit 7a8cbc60a5
2 changed files with 26 additions and 7 deletions

View File

@ -181,6 +181,15 @@ as a side-effect of generating sources.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--generate-phony-targets</option></term>
<listitem><para>
When creating a dependency file with <option>--dependency-file</option>
include phony targets in the same style as gcc -MP. This would typically
be used with <literal>make</literal>.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>

View File

@ -612,6 +612,7 @@ main (int argc, char **argv)
gboolean manual_register = FALSE;
gboolean internal = FALSE;
gboolean generate_dependencies = FALSE;
gboolean generate_phony_targets = FALSE;
char *dependency_file = NULL;
char *c_name = NULL;
char *c_name_no_underscores;
@ -626,6 +627,7 @@ main (int argc, char **argv)
{ "generate-source", 0, 0, G_OPTION_ARG_NONE, &generate_source, N_("Generate sourcecode used to link in the resource file into your code"), NULL },
{ "generate-dependencies", 0, 0, G_OPTION_ARG_NONE, &generate_dependencies, N_("Generate dependency list"), NULL },
{ "dependency-file", 0, 0, G_OPTION_ARG_FILENAME, &dependency_file, N_("name of the dependency file to generate"), N_("FILE") },
{ "generate-phony-targets", 0, 0, G_OPTION_ARG_NONE, &generate_phony_targets, N_("Include phony targets in the generated dependency file"), NULL },
{ "manual-register", 0, 0, G_OPTION_ARG_NONE, &manual_register, N_("Dont automatically create and register resource"), NULL },
{ "internal", 0, 0, G_OPTION_ARG_NONE, &internal, N_("Dont export functions; declare them G_GNUC_INTERNAL"), NULL },
{ "c-name", 0, 0, G_OPTION_ARG_STRING, &c_name, N_("C identifier name used for the generated source code"), NULL },
@ -772,7 +774,14 @@ main (int argc, char **argv)
g_string_append_printf (dep_string, " %s", file_data->filename);
}
g_string_append (dep_string, "\n\n");
g_string_append (dep_string, "\n");
/* Optionally include phony targets as it silences `make` but
* isn't supported on `ninja` at the moment. See also: `gcc -MP`
*/
if (generate_phony_targets)
{
g_string_append (dep_string, "\n");
/* One rule for every resource: resourceN: */
g_hash_table_iter_init (&iter, files);
@ -782,6 +791,7 @@ main (int argc, char **argv)
if (!g_str_equal (file_data->filename, srcfile))
g_string_append_printf (dep_string, "%s:\n\n", file_data->filename);
}
}
if (g_str_equal (dependency_file, "-"))
{