summaryrefslogtreecommitdiff
path: root/giscanner/dumper.py
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 /giscanner/dumper.py
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
Diffstat (limited to 'giscanner/dumper.py')
-rw-r--r--giscanner/dumper.py63
1 files changed, 25 insertions, 38 deletions
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):