[glib] Revert "glib-compile-resources: generate .d-file style dependency output for build tools"
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Revert "glib-compile-resources: generate .d-file style dependency output for build tools"
- Date: Sat, 20 Aug 2016 16:17:04 +0000 (UTC)
commit 9afff5f05decc20094130a9bf9b2b907acca4bc6
Author: Emmanuele Bassi <ebassi gnome org>
Date: Sat Aug 20 17:16:31 2016 +0100
Revert "glib-compile-resources: generate .d-file style dependency output for build tools"
This reverts commit e8c8395f0e72f59e37189e94b08052bebb51ac77.
Tim said that the patch isn't ready, yet, and the commit is breaking the
build in Continuous.
docs/reference/gio/glib-compile-resources.xml | 14 ----
gio/glib-compile-resources.c | 89 ++++++-------------------
2 files changed, 22 insertions(+), 81 deletions(-)
---
diff --git a/docs/reference/gio/glib-compile-resources.xml b/docs/reference/gio/glib-compile-resources.xml
index c2c1989..fcce89a 100644
--- a/docs/reference/gio/glib-compile-resources.xml
+++ b/docs/reference/gio/glib-compile-resources.xml
@@ -124,9 +124,6 @@ test.gresource: test.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-
</programlisting>
Note that this may or may not be portable to non-GNU <command>make</command>.
</para>
-<para>
-Also see <option>--dependency-file</option>.
-</para>
</listitem>
</varlistentry>
@@ -163,17 +160,6 @@ which is what <option>--internal</option> does.
</para></listitem>
</varlistentry>
-<varlistentry>
-<term><option>--dependency-file=<replaceable>FILE</replaceable></option></term>
-<listitem><para>
-Write dependencies in the same style as gcc -M -MF to the given file.
-If <option>FILE</option> is -, the dependencies are written to the standard
-output. Unlike <option>--generate-dependencies</option>, this option can be
-combined with other <option>--generate</option> options to generate dependencies
-as a side-effect of generating sources.
-</para></listitem>
-</varlistentry>
-
</variablelist>
</refsect1>
diff --git a/gio/glib-compile-resources.c b/gio/glib-compile-resources.c
index 7c35bf3..71a0f48 100644
--- a/gio/glib-compile-resources.c
+++ b/gio/glib-compile-resources.c
@@ -61,6 +61,8 @@ typedef struct
{
GHashTable *table; /* resource path -> FileData */
+ gboolean collect_data;
+
/* per gresource */
char *prefix;
@@ -240,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);
@@ -251,7 +253,7 @@ 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);
@@ -264,6 +266,8 @@ end_element (GMarkupParseContext *context,
data = g_new0 (FileData, 1);
data->filename = g_strdup (real_file);
+ if (!state->collect_data)
+ goto done;
if (state->preproc_options)
{
@@ -411,6 +415,8 @@ end_element (GMarkupParseContext *context,
data->flags |= G_RESOURCE_FLAGS_COMPRESSED;
}
+ done:
+
g_hash_table_insert (state->table, key, data);
data = NULL;
@@ -470,7 +476,7 @@ text (GMarkupParseContext *context,
static GHashTable *
parse_resource_file (const gchar *filename,
- GHashTable *files)
+ gboolean collect_data)
{
GMarkupParser parser = { start_element, end_element, text };
ParseState state = { 0, };
@@ -487,7 +493,8 @@ parse_resource_file (const gchar *filename,
return NULL;
}
- state.table = g_hash_table_ref (files);
+ state.table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)file_data_free);
+ state.collect_data = collect_data;
context = g_markup_parse_context_new (&parser,
G_MARKUP_TREAT_CDATA_AS_TEXT |
@@ -500,7 +507,7 @@ parse_resource_file (const gchar *filename,
g_printerr ("%s: %s.\n", filename, error->message);
g_clear_error (&error);
}
- else
+ else if (collect_data)
{
GHashTableIter iter;
const char *key;
@@ -540,6 +547,10 @@ parse_resource_file (const gchar *filename,
g_variant_builder_end (&builder));
}
}
+ else
+ {
+ table = g_hash_table_ref (state.table);
+ }
g_hash_table_unref (state.table);
g_markup_parse_context_free (context);
@@ -594,7 +605,6 @@ main (int argc, char **argv)
{
GError *error;
GHashTable *table;
- GHashTable *files;
gchar *srcfile;
gchar *target = NULL;
gchar *binary_target = NULL;
@@ -604,7 +614,6 @@ main (int argc, char **argv)
gboolean manual_register = FALSE;
gboolean internal = FALSE;
gboolean generate_dependencies = FALSE;
- char *dependency_file = NULL;
char *c_name = NULL;
char *c_name_no_underscores;
const char *linkage = "extern";
@@ -616,7 +625,6 @@ main (int argc, char **argv)
{ "generate-header", 0, 0, G_OPTION_ARG_NONE, &generate_header, N_("Generate source header"), NULL },
{ "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") },
{ "manual-register", 0, 0, G_OPTION_ARG_NONE, &manual_register, N_("Don't automatically create and
register resource"), NULL },
{ "internal", 0, 0, G_OPTION_ARG_NONE, &internal, N_("Don't 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 },
@@ -724,77 +732,24 @@ main (int argc, char **argv)
;
}
- files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)file_data_free);
-
- if ((table = parse_resource_file (srcfile, files)) == NULL)
+ if ((table = parse_resource_file (srcfile, !generate_dependencies)) == NULL)
{
g_free (target);
g_free (c_name);
return 1;
}
- if (generate_dependencies || dependency_file != NULL)
+ if (generate_dependencies)
{
GHashTableIter iter;
gpointer key, data;
FileData *file_data;
- g_hash_table_iter_init (&iter, files);
- if (dependency_file == NULL)
+ g_hash_table_iter_init (&iter, table);
+ while (g_hash_table_iter_next (&iter, &key, &data))
{
- /* Generate list of files for direct use as dependencies in a Makefile */
- while (g_hash_table_iter_next (&iter, &key, &data))
- {
- file_data = data;
- g_print ("%s\n", file_data->filename);
- }
- }
- else
- {
- /* Generate a .d file that describes the dependencies for
- * build tools, gcc -M -MF style */
- GString *dep_string;
-
- dep_string = g_string_new (NULL);
- g_string_printf (dep_string, "%s:", srcfile);
-
- /* First rule: foo.xml: resource1 resource2.. */
- while (g_hash_table_iter_next (&iter, &key, &data))
- {
- file_data = data;
- if (!g_str_equal (file_data->filename, srcfile))
- g_string_append_printf (dep_string, " %s", file_data->filename);
- }
-
- g_string_append (dep_string, "\n\n");
-
- /* One rule for every resource: resourceN: */
- g_hash_table_iter_init (&iter, files);
- while (g_hash_table_iter_next (&iter, &key, &data))
- {
- file_data = data;
- 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, "-"))
- {
- g_print ("%s\n", dep_string->str);
- }
- else
- {
- if (!g_file_set_contents (dependency_file, dep_string->str, dep_string->len, &error))
- {
- g_printerr ("Error writing dependency file: %s\n", error->message);
- g_string_free (dep_string, TRUE);
- g_free (dependency_file);
- g_error_free (error);
- return 1;
- }
- }
-
- g_string_free (dep_string, TRUE);
- g_free (dependency_file);
+ file_data = data;
+ g_print ("%s\n",file_data->filename);
}
}
else if (generate_source || generate_header)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]