summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2010-09-30 10:44:12 -0400
committerColin Walters <walters@verbum.org>2010-09-30 13:47:25 -0400
commit82e08ec5f5f2440ed5be2e5ca5954ebac2eb7775 (patch)
tree90512dfae632254505c8dcabffe376fd2bef194e
parentebef2cf9f1c5de556afd839e0a4c13db373d4a50 (diff)
downloadgobject-introspection-82e08ec5f5f2440ed5be2e5ca5954ebac2eb7775.tar.gz
scanner: Don't link to -lgirepository when dumpingGOBJECT_INTROSPECTION_0_9_9
This helps us avoid a problematic case where in say jhbuild, using a system (/usr/lib) glib, adding in -l girepository-1.0 will inject -L /path/to/builddir, when we don't want that. https://bugzilla.gnome.org/show_bug.cgi?id=630342
-rw-r--r--girepository/Makefile.am4
-rw-r--r--girepository/gdump.c9
-rw-r--r--giscanner/dumper.py63
3 files changed, 36 insertions, 40 deletions
diff --git a/girepository/Makefile.am b/girepository/Makefile.am
index e0f2b1ba..16873220 100644
--- a/girepository/Makefile.am
+++ b/girepository/Makefile.am
@@ -53,7 +53,7 @@ libgirepository_1_0_la_SOURCES = \
giunioninfo.c \
givfuncinfo.c
-libgirepository_1_0_la_CPPFLAGS = $(GIREPO_CFLAGS)
+libgirepository_1_0_la_CPPFLAGS = $(GIREPO_CFLAGS) -DG_IREPOSITORY_COMPILATION
libgirepository_1_0_la_LIBADD = $(GIREPO_LIBS)
libgirepository_1_0_la_LDFLAGS = -no-undefined -version-number 1:0:0
@@ -69,3 +69,5 @@ libgirepository_parser_la_SOURCES = \
girwriter.h
libgirepository_parser_la_CFLAGS = $(GIREPO_CFLAGS)
+gdumpdir = $(datadir)/gobject-introspection-1.0/
+gdump_DATA = gdump.c
diff --git a/girepository/gdump.c b/girepository/gdump.c
index 84ac3c71..166a9e72 100644
--- a/girepository/gdump.c
+++ b/girepository/gdump.c
@@ -24,8 +24,15 @@
#include <glib-object.h>
#include <gio/gio.h>
-#include "girepository.h"
+/* This file is both compiled into libgirepository.so, and installed
+ * on the filesystem. But for the dumper, we want to avoid linking
+ * to libgirepository; see
+ * https://bugzilla.gnome.org/show_bug.cgi?id=630342
+ */
+#ifdef G_IREPOSITORY_COMPILATION
#include "config.h"
+#include "girepository.h"
+#endif
#include <string.h>
diff --git a/giscanner/dumper.py b/giscanner/dumper.py
index 96f29371..26ddd7b7 100644
--- a/giscanner/dumper.py
+++ b/giscanner/dumper.py
@@ -25,6 +25,7 @@ import tempfile
from .gdumpparser import IntrospectionBinary
from .utils import get_libtool_command
+from .config import DATADIR
# bugzilla.gnome.org/558436
# Compile a binary program which is then linked to a library
@@ -32,36 +33,34 @@ from .utils import get_libtool_command
_PROGRAM_TEMPLATE = """/* This file is generated, do not edit */
#include <glib.h>
-#include <girepository.h>
#include <string.h>
+#include <stdlib.h>
-static GOptionEntry entries[] =
-{
- { NULL }
-};
+%(gdump_include)s
int
main(int argc, char **argv)
{
- GOptionContext *context;
GError *error = NULL;
+ const char *introspect_dump_prefix = "--introspect-dump=";
if (!g_thread_supported ()) g_thread_init (NULL);
g_type_init ();
%(init_sections)s
- context = g_option_context_new ("");
- g_option_context_add_main_entries (context, entries, "girepository-1.0");
- g_option_context_add_group (context, g_irepository_get_option_group ());
- if (!g_option_context_parse (context, &argc, &argv, &error))
+ if (argc != 2 || !g_str_has_prefix (argv[1], introspect_dump_prefix))
{
- g_printerr ("introspect failed (%%d,%%d): %%s\\n",
- error->domain, error->code,
- error->message);
- return 1;
+ g_printerr ("Usage: %%s --introspect-dump=input,output", argv[0]);
+ exit (1);
}
- return 0;
+
+ if (!g_irepository_dump (argv[1] + strlen(introspect_dump_prefix), &error))
+ {
+ g_printerr ("%%s\\n", error->message);
+ exit (1);
+ }
+ exit (0);
}
"""
@@ -90,13 +89,22 @@ class DumpCompiler(object):
self._uninst_srcdir = os.environ.get(
'UNINSTALLED_INTROSPECTION_SRCDIR')
self._packages = ['gio-2.0 gthread-2.0']
- if not self._uninst_srcdir:
- self._packages.append('gobject-introspection-1.0')
# Public API
def run(self):
tpl_args = {}
+ if self._uninst_srcdir is not None:
+ gdump_path = os.path.join(self._uninst_srcdir, 'girepository', 'gdump.c')
+ else:
+ gdump_path = os.path.join(os.path.join(DATADIR), 'gobject-introspection-1.0',
+ 'gdump.c')
+ if not os.path.isfile(gdump_path):
+ raise SystemExit("Couldn't find %r" % (gdump_path, ))
+ gdump_file = open(gdump_path)
+ gdump_contents = gdump_file.read()
+ gdump_file.close()
+ tpl_args['gdump_include'] = gdump_contents
tpl_args['init_sections'] = "\n".join(self._options.init_sections)
c_path = self._generate_tempfile('.c')
@@ -156,9 +164,6 @@ class DumpCompiler(object):
if self._compiler_cmd == 'gcc' and not self._options.init_sections:
args.append('-Wall')
pkgconfig_flags = self._run_pkgconfig('--cflags')
- if self._uninst_srcdir:
- args.append('-I' + os.path.join(self._uninst_srcdir,
- 'girepository'))
args.extend(pkgconfig_flags)
cflags = os.environ.get('CFLAGS')
if (cflags):
@@ -204,30 +209,12 @@ class DumpCompiler(object):
if not libtool:
args.append('-Wl,-rpath=.')
- uninst_builddir = os.environ.get('UNINSTALLED_INTROSPECTION_BUILDDIR')
- if not uninst_builddir:
- proc = subprocess.Popen([self._pkgconfig_cmd, '--libs',
- 'gobject-introspection-1.0'],
- stdout=subprocess.PIPE)
- args.extend(proc.communicate()[0].split())
- # hack for building GIRepository.gir, skip -lgirepository-1.0 since
- # libgirepository-1.0.la is not in current directory and we refer to it
- # explicitly below anyway
for library in self._options.libraries:
- if (uninst_builddir and
- self._options.libraries[0] == 'girepository-1.0'):
- continue
if library.endswith(".la"): # explicitly specified libtool library
args.append(library)
else:
args.append('-l' + library)
- # hack for building gobject-introspection itself
- if uninst_builddir:
- path = os.path.join(uninst_builddir, 'girepository',
- 'libgirepository-1.0.la')
- args.append(path)
-
args.extend(self._run_pkgconfig('--libs'))
for source in sources:
if not os.path.exists(source):