mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 15:36:17 +01:00
Put dependencies in typelibs, resolve them when loading
* gir/Makefile.am: Dep on Makefile * girepository/ginfo.c: Print out a nicer error message if we failed to load something. * girepository/girepository.c: Clean up default typelib handling; remove global default_typelib variable. Ensure we handle NULL repository in more places. Support dependency resolution. * tests/Makefile.am: Kill off gobject.gir, it conflicts with the real one. * tests/Object.gir: Depend on GObject. * tools/generate.c: Take --includedir argument to say which directories to search for typelibs. Print out dependencies. svn path=/trunk/; revision=541
This commit is contained in:
parent
56428ae349
commit
030b17bc9f
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
/* FIXME: Avoid global */
|
/* FIXME: Avoid global */
|
||||||
static gchar *output = NULL;
|
static gchar *output = NULL;
|
||||||
|
gchar **includedirs = NULL;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
write_type_name (const gchar *namespace,
|
write_type_name (const gchar *namespace,
|
||||||
@ -371,7 +372,7 @@ write_function_info (const gchar *namespace,
|
|||||||
|
|
||||||
if (deprecated)
|
if (deprecated)
|
||||||
g_fprintf (file, " deprecated=\"1\"");
|
g_fprintf (file, " deprecated=\"1\"");
|
||||||
|
|
||||||
write_callable_info (namespace, (GICallableInfo*)info, file, indent);
|
write_callable_info (namespace, (GICallableInfo*)info, file, indent);
|
||||||
g_fprintf (file, "%*s</%s>\n", indent, "", tag);
|
g_fprintf (file, "%*s</%s>\n", indent, "", tag);
|
||||||
}
|
}
|
||||||
@ -1002,15 +1003,16 @@ write_union_info (const gchar *namespace,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
write_repository (GIRepository *repository,
|
write_repository (const char *namespace,
|
||||||
gboolean needs_prefix)
|
gboolean needs_prefix)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
gchar **namespaces;
|
|
||||||
gchar *ns;
|
gchar *ns;
|
||||||
gint i, j;
|
gint i, j;
|
||||||
|
char **dependencies;
|
||||||
|
GIRepository *repository;
|
||||||
|
|
||||||
namespaces = g_irepository_get_namespaces (repository);
|
repository = g_irepository_get_default ();
|
||||||
|
|
||||||
if (output == NULL)
|
if (output == NULL)
|
||||||
file = stdout;
|
file = stdout;
|
||||||
@ -1019,7 +1021,7 @@ write_repository (GIRepository *repository,
|
|||||||
gchar *filename;
|
gchar *filename;
|
||||||
|
|
||||||
if (needs_prefix)
|
if (needs_prefix)
|
||||||
filename = g_strdup_printf ("%s-%s", namespaces[0], output);
|
filename = g_strdup_printf ("%s-%s", namespace, output);
|
||||||
else
|
else
|
||||||
filename = g_strdup (output);
|
filename = g_strdup (output);
|
||||||
file = g_fopen (filename, "w");
|
file = g_fopen (filename, "w");
|
||||||
@ -1042,10 +1044,21 @@ write_repository (GIRepository *repository,
|
|||||||
" xmlns:c=\"http://www.gtk.org/introspection/c/1.0\"\n"
|
" xmlns:c=\"http://www.gtk.org/introspection/c/1.0\"\n"
|
||||||
" xmlns:glib=\"http://www.gtk.org/introspection/glib/1.0\">\n");
|
" xmlns:glib=\"http://www.gtk.org/introspection/glib/1.0\">\n");
|
||||||
|
|
||||||
for (i = 0; namespaces[i]; i++)
|
dependencies = g_irepository_get_dependencies (repository,
|
||||||
|
namespace);
|
||||||
|
if (dependencies != NULL)
|
||||||
|
{
|
||||||
|
for (i = 0; dependencies[i]; i++)
|
||||||
|
{
|
||||||
|
g_fprintf (file, " <include name=\"%s\"/>\n", dependencies[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TRUE)
|
||||||
{
|
{
|
||||||
const gchar *shared_library;
|
const gchar *shared_library;
|
||||||
ns = namespaces[i];
|
const char *ns = namespace;
|
||||||
|
|
||||||
shared_library = g_irepository_get_shared_library (repository, ns);
|
shared_library = g_irepository_get_shared_library (repository, ns);
|
||||||
if (shared_library)
|
if (shared_library)
|
||||||
g_fprintf (file, " <namespace name=\"%s\" shared-library=\"%s\">\n",
|
g_fprintf (file, " <namespace name=\"%s\" shared-library=\"%s\">\n",
|
||||||
@ -1110,8 +1123,6 @@ write_repository (GIRepository *repository,
|
|||||||
|
|
||||||
if (output != NULL)
|
if (output != NULL)
|
||||||
fclose (file);
|
fclose (file);
|
||||||
|
|
||||||
g_strfreev (namespaces);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const guchar *
|
static const guchar *
|
||||||
@ -1167,10 +1178,13 @@ main (int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
{ "shlib", 0, 0, G_OPTION_ARG_NONE, &shlib, "handle typelib embedded in shlib", NULL },
|
{ "shlib", 0, 0, G_OPTION_ARG_NONE, &shlib, "handle typelib embedded in shlib", NULL },
|
||||||
{ "output", 'o', 0, G_OPTION_ARG_FILENAME, &output, "output file", "FILE" },
|
{ "output", 'o', 0, G_OPTION_ARG_FILENAME, &output, "output file", "FILE" },
|
||||||
|
{ "includedir", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &includedirs, "include directories in GIR search path", NULL },
|
||||||
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &input, NULL, NULL },
|
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &input, NULL, NULL },
|
||||||
{ NULL, }
|
{ NULL, }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL);
|
||||||
|
|
||||||
g_type_init ();
|
g_type_init ();
|
||||||
|
|
||||||
g_typelib_check_sanity ();
|
g_typelib_check_sanity ();
|
||||||
@ -1186,11 +1200,16 @@ main (int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (includedirs != NULL)
|
||||||
|
for (i = 0; includedirs[i]; i++)
|
||||||
|
g_irepository_prepend_search_path (includedirs[i]);
|
||||||
|
|
||||||
for (i = 0; input[i]; i++)
|
for (i = 0; input[i]; i++)
|
||||||
{
|
{
|
||||||
GModule *dlhandle = NULL;
|
GModule *dlhandle = NULL;
|
||||||
const guchar *typelib;
|
const guchar *typelib;
|
||||||
gsize len;
|
gsize len;
|
||||||
|
const char *namespace;
|
||||||
|
|
||||||
if (!shlib)
|
if (!shlib)
|
||||||
{
|
{
|
||||||
@ -1224,12 +1243,18 @@ main (int argc, char *argv[])
|
|||||||
if (!g_typelib_validate (data, &error)) {
|
if (!g_typelib_validate (data, &error)) {
|
||||||
g_printerr ("typelib not valid: %s\n", error->message);
|
g_printerr ("typelib not valid: %s\n", error->message);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_irepository_register (g_irepository_get_default (), data);
|
namespace = g_irepository_load_typelib (g_irepository_get_default (), data,
|
||||||
write_repository (g_irepository_get_default (), needs_prefix);
|
&error);
|
||||||
g_irepository_unregister (g_irepository_get_default (),
|
if (namespace == NULL)
|
||||||
g_typelib_get_namespace (data));
|
{
|
||||||
|
g_printerr ("failed to load typelib: %s\n", error->message);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
write_repository (namespace, needs_prefix);
|
||||||
|
|
||||||
if (dlhandle)
|
if (dlhandle)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user