diff options
Diffstat (limited to 'giscanner/utils.py')
-rw-r--r-- | giscanner/utils.py | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/giscanner/utils.py b/giscanner/utils.py index e3396c6e..a49aca6b 100644 --- a/giscanner/utils.py +++ b/giscanner/utils.py @@ -23,6 +23,7 @@ import os import subprocess import platform import shutil +import sys import time import giscanner.pkgconfig @@ -83,7 +84,7 @@ _libtool_pat = re.compile("dlname='([A-z0-9\\.\\-\\+]+)'\n") def _extract_dlname_field(la_file): - with open(la_file) as f: + with open(la_file, encoding='utf-8') as f: data = f.read() m = _libtool_pat.search(data) if m: @@ -96,7 +97,7 @@ _libtool_libdir_pat = re.compile("libdir='([^']+)'") def _extract_libdir_field(la_file): - with open(la_file) as f: + with open(la_file, encoding='utf-8') as f: data = f.read() m = _libtool_libdir_pat.search(data) if m: @@ -120,24 +121,10 @@ def extract_libtool_shlib(la_file): if libdir is None: return dlbasename return libdir + '/' + dlbasename - # From the comments in extract_libtool(), older libtools had - # a path rather than the raw dlname + # Older libtools had a path rather than the raw dlname return os.path.basename(dlname) -def extract_libtool(la_file): - dlname = _extract_dlname_field(la_file) - if dlname is None: - raise ValueError("%s has no dlname. Not a shared library?" % la_file) - libname = os.path.join(os.path.dirname(la_file), - '.libs', dlname) - # FIXME: This hackish, but I'm not sure how to do this - # in a way which is compatible with both libtool 2.2 - # and pre-2.2. Johan 2008-10-21 - libname = libname.replace('.libs/.libs', '.libs').replace('.libs\\.libs', '.libs') - return libname - - # Returns arguments for invoking libtool, if applicable, otherwise None def get_libtool_command(options): libtool_infection = not options.nolibtool @@ -318,3 +305,32 @@ class dll_dirs(): added_dll_dir.close() if self._cached_dll_dirs is not None: self._cached_dll_dirs.clear() + + +# monkey patch distutils.cygwinccompiler +# somehow distutils returns runtime library only up to +# VS2010 / MSVC 10.0 (msc_ver 1600) +def get_msvcr_overwrite(): + try: + return orig_get_msvcr() + except ValueError: + pass + + msc_pos = sys.version.find('MSC v.') + if msc_pos != -1: + msc_ver = sys.version[msc_pos + 6:msc_pos + 10] + + if msc_ver == '1700': + # VS2012 + return ['msvcr110'] + elif msc_ver == '1800': + # VS2013 + return ['msvcr120'] + elif msc_ver >= '1900': + # VS2015 + return ['vcruntime140'] + + +import distutils.cygwinccompiler +orig_get_msvcr = distutils.cygwinccompiler.get_msvcr +distutils.cygwinccompiler.get_msvcr = get_msvcr_overwrite |