From 19040edfd027b86ac60139557cc5dee5dbd7fc04 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 20 Oct 2010 10:42:17 -0400 Subject: dumper: Differentiate between "external" and "internal" linking The previous commit aea515709 broke scanning for libraries not in the current directory, such as scanning Gio from gobject-introspection. In this case, it's wrong to add -L., and to move the other -L behind the library. Instead, we should just do a "normal" link using pkg-config --libs with few games. https://bugzilla.gnome.org/show_bug.cgi?id=632701 --- Makefile-gir.am | 4 ++++ giscanner/dumper.py | 46 ++++++++++++++++++++++++++++++++++------------ giscanner/scannermain.py | 3 +++ 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/Makefile-gir.am b/Makefile-gir.am index 169f4623..062eb85b 100644 --- a/Makefile-gir.am +++ b/Makefile-gir.am @@ -53,6 +53,7 @@ endif GLib_2_0_gir_LIBS = $(GLIB_LIBRARY) GLib_2_0_gir_SCANNERFLAGS = \ + --external-library \ --reparse-validate \ --identifier-prefix=G \ --symbol-prefix=g \ @@ -91,6 +92,7 @@ GObject-2.0.gir: GLib-2.0.gir GObject_2_0_gir_LIBS = $(GOBJECT_LIBRARY) GObject_2_0_gir_SCANNERFLAGS = \ + --external-library \ --reparse-validate \ --identifier-prefix=G \ --c-include="glib-object.h" \ @@ -121,6 +123,7 @@ GModule-2.0.gir: GLib-2.0.gir GModule_2_0_gir_LIBS = $(GMODULE_LIBRARY) GModule_2_0_gir_SCANNERFLAGS = \ + --external-library \ --identifier-prefix=G \ --c-include="gmodule.h" \ --add-include-path=. \ @@ -157,6 +160,7 @@ Gio-2.0.gir: GObject-2.0.gir Gio_2_0_gir_LIBS = $(GIO_LIBRARY) Gio_2_0_gir_SCANNERFLAGS = \ + --external-library \ --reparse-validate \ --warn-all \ --identifier-prefix=G \ diff --git a/giscanner/dumper.py b/giscanner/dumper.py index e44f4f4a..9b4033c7 100644 --- a/giscanner/dumper.py +++ b/giscanner/dumper.py @@ -214,6 +214,29 @@ class DumpCompiler(object): # likely to be uninstalled yet and we want the uninstalled RPATHs have # priority (or we might run with installed library that is older) + if not self._options.external_library: + self._add_link_internal_args(args, libtool) + else: + self._add_link_external_args(args) + + for source in sources: + if not os.path.exists(source): + raise CompilerError( + "Could not find object file: %s" % (source, )) + args.extend(list(sources)) + + if not self._options.quiet: + print "g-ir-scanner: link: %s" % ( + subprocess.list2cmdline(args), ) + try: + subprocess.check_call(args) + except subprocess.CalledProcessError, e: + raise LinkerError(e) + + def _add_link_internal_args(self, args, libtool): + # An "internal" link is where the library to be introspected + # is being built in the current directory. + # Search the current directory first args.append('-L.') @@ -231,19 +254,18 @@ class DumpCompiler(object): args.append('-L' + library_path) args.extend(self._run_pkgconfig('--libs')) - for source in sources: - if not os.path.exists(source): - raise CompilerError( - "Could not find object file: %s" % (source, )) - args.extend(list(sources)) - if not self._options.quiet: - print "g-ir-scanner: link: %s" % ( - subprocess.list2cmdline(args), ) - try: - subprocess.check_call(args) - except subprocess.CalledProcessError, e: - raise LinkerError(e) + def _add_link_external_args(self, args): + # An "external" link is where the library to be introspected + # is installed on the system; this case is used for the scanning + # of GLib in gobject-introspection itself. + + args.extend(self._run_pkgconfig('--libs')) + for library in self._options.libraries: + if library.endswith(".la"): # explicitly specified libtool library + args.append(library) + else: + args.append('-l' + library) def compile_introspection_binary(options, get_type_functions): dc = DumpCompiler(options, get_type_functions) diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py index dd186435..79d85c55 100644 --- a/giscanner/scannermain.py +++ b/giscanner/scannermain.py @@ -90,6 +90,9 @@ def _get_option_parser(): parser.add_option("", "--no-libtool", action="store_true", dest="nolibtool", default=False, help="do not use libtool") + parser.add_option("", "--external-library", + action="store_true", dest="external_library", default=False, + help="If true, the library is located on the system, not in the current directory") parser.add_option("-l", "--library", action="append", dest="libraries", default=[], help="libraries of this unit") -- cgit v1.2.1