[gobject-introspection] scanner: Add a way to specify extra libraries to link against



commit eea2447c4e4c1c98fda3ba212a9a9bbcc8655c90
Author: Thibault Saunier <thibault saunier osg samsung com>
Date:   Thu Nov 17 12:01:14 2016 -0300

    scanner: Add a way to specify extra libraries to link against
    
    Currently the only way to get a library to link against the dumper
    program is through '--link' which implies that library will be defined
    in the 'libraries' field of the .gir. When using libtool, we
    link against dependencies of that library as the .la defines that, but
    when using --no-libtool that won't happen and the user needs to be
    able to define to what other libraries the program needs to be link
    against, and this is what the new --extra-library argument is about.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=774625

 giscanner/ccompiler.py   |    6 +++---
 giscanner/dumper.py      |    1 +
 giscanner/scannermain.py |    3 +++
 3 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py
index 57df9d6..11bc9fc 100644
--- a/giscanner/ccompiler.py
+++ b/giscanner/ccompiler.py
@@ -108,14 +108,14 @@ class CCompiler(object):
 
             self._cflags_no_deprecation_warnings = "-Wno-deprecated-declarations"
 
-    def get_internal_link_flags(self, args, libtool, libraries, libpaths):
+    def get_internal_link_flags(self, args, libtool, libraries, extra_libraries, libpaths):
         # An "internal" link is where the library to be introspected
         # is being built in the current directory.
 
         if not libtool:
             # non-libtool case: prepare distutils use
             if self.check_is_msvc():
-                for library in libraries:
+                for library in libraries + extra_libraries:
                     # MSVC Builds don't use libtool, so no .la libraries,
                     # so just add the library directly.
                     self.compiler.add_library(library)
@@ -136,7 +136,7 @@ class CCompiler(object):
                 if sys.platform != 'darwin':
                     args.append('-Wl,--no-as-needed')
 
-            for library in libraries:
+            for library in libraries + extra_libraries:
                 self.compiler.add_library(library)
             if not self.check_is_msvc():
                 for library_path in libpaths:
diff --git a/giscanner/dumper.py b/giscanner/dumper.py
index 3f72159..9077d20 100644
--- a/giscanner/dumper.py
+++ b/giscanner/dumper.py
@@ -259,6 +259,7 @@ class DumpCompiler(object):
             self._compiler.get_internal_link_flags(args,
                                                    libtool,
                                                    self._options.libraries,
+                                                   self._options.extra_libraries,
                                                    self._options.library_paths)
             args.extend(pkg_config_libs)
 
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index 633496f..095a43f 100755
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -140,6 +140,9 @@ def _get_option_parser():
     parser.add_option("-l", "--library",
                       action="append", dest="libraries", default=[],
                       help="libraries of this unit")
+    parser.add_option("", "--extra-library",
+                      action="append", dest="extra_libraries", default=[],
+                      help="Extra libraries to link the binary against")
     parser.add_option("-L", "--library-path",
                       action="append", dest="library_paths", default=[],
                       help="directories to search for libraries")


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]