summaryrefslogtreecommitdiff
path: root/giscanner/dumper.py
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2014-08-01 20:21:13 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2014-08-05 17:57:49 +0800
commitc930859297c32e52f8cad0914dec2cdd7eff18dc (patch)
tree2f8e22b272db18dcf397bc096632c87a85743b9b /giscanner/dumper.py
parent3701b320a53de2920ffb96982b40d8204d95d504 (diff)
downloadgobject-introspection-c930859297c32e52f8cad0914dec2cdd7eff18dc.tar.gz
giscanner: Add New CCompiler Module
This adds a CCompiler module for the giscanner Python scripts so that items related to the run of the preprocessor, compiler and linker can be done in this module, and this marks the beginning of the move of building the introspection files using Python's distutils. This patch first moves _add_[internal|external]_link_flags() to ccompiler.py as get_[internal|external]_link_flags and also moves the Windows shlibs resolution (deducing the DLLs the introspection files should link to from the libraries passed in) in shlibs.py to resolve_windows_libs() in ccompiler.py https://bugzilla.gnome.org/show_bug.cgi?id=728313
Diffstat (limited to 'giscanner/dumper.py')
-rw-r--r--giscanner/dumper.py87
1 files changed, 16 insertions, 71 deletions
diff --git a/giscanner/dumper.py b/giscanner/dumper.py
index ce119619..45a09fc8 100644
--- a/giscanner/dumper.py
+++ b/giscanner/dumper.py
@@ -27,6 +27,7 @@ import tempfile
from .gdumpparser import IntrospectionBinary
from . import utils
+from .ccompiler import CCompiler
# bugzilla.gnome.org/558436
# Compile a binary program which is then linked to a library
@@ -287,10 +288,23 @@ class DumpCompiler(object):
"Could not find object file: %s" % (source, ))
args.extend(list(sources))
+ cc = CCompiler()
+
if not self._options.external_library:
- self._add_link_internal_args(args, libtool)
+ cc.get_internal_link_flags(args,
+ libtool,
+ self._options.libraries,
+ self._options.library_paths,
+ self._pkgconfig_msvc_flags,
+ self._options.namespace_name,
+ self._options.namespace_version)
+ args.extend(self._run_pkgconfig('--libs'))
+
else:
- self._add_link_external_args(args)
+ args.extend(self._run_pkgconfig('--libs'))
+ cc.get_external_link_flags(args,
+ self._options.libraries,
+ self._pkgconfig_msvc_flags)
if not self._options.quiet:
print "g-ir-scanner: link: %s" % (
@@ -317,75 +331,6 @@ class DumpCompiler(object):
if msys:
os.remove(tf_name)
- 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
- # (This flag is not supported nor needed for Visual C++)
- if self._pkgconfig_msvc_flags == '':
- args.append('-L.')
-
- # https://bugzilla.gnome.org/show_bug.cgi?id=625195
- if not libtool:
- # We don't have -Wl,-rpath for Visual C++, and that's
- # going to cause a problem. Instead, link to internal
- # libraries by deducing the .lib file name using
- # the namespace name and version
- if self._pkgconfig_msvc_flags:
- if self._options.namespace_version:
- args.append(str.lower(self._options.namespace_name) +
- '-' +
- self._options.namespace_version + '.lib')
- else:
- args.append(str.lower(self._options.namespace_name) + '.lib')
- else:
- args.append('-Wl,-rpath=.')
-
- # Ensure libraries are always linked as we are going to use ldd to work
- # out their names later
- if not libtool and self._pkgconfig_msvc_flags == '':
- args.append('-Wl,--no-as-needed')
-
- for library in self._options.libraries:
- # Visual C++: We have the needed .lib files now, and we need to link
- # to .lib files, not the .dll as the --library option specifies the
- # .dll(s) the .gir file refers to
- if self._pkgconfig_msvc_flags == '':
- if library.endswith(".la"): # explicitly specified libtool library
- args.append(library)
- else:
- args.append('-l' + library)
-
- for library_path in self._options.library_paths:
- # Not used/needed on Visual C++, and -Wl,-rpath options
- # will cause grief
- if self._pkgconfig_msvc_flags == '':
- args.append('-L' + library_path)
- if os.path.isabs(library_path):
- if libtool:
- args.append('-rpath')
- args.append(library_path)
- else:
- args.append('-Wl,-rpath=' + library_path)
-
- args.extend(self._run_pkgconfig('--libs'))
-
- 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:
- # The --library option on Windows pass in the .dll file(s) the
- # .gir files refer to, so don't link to them on Visual C++
- if self._pkgconfig_msvc_flags == '':
- if library.endswith(".la"): # explicitly specified libtool library
- args.append(library)
- else:
- args.append('-l' + library)
-
def compile_introspection_binary(options, get_type_functions,
error_quark_functions):