summaryrefslogtreecommitdiff
path: root/giscanner/shlibs.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/shlibs.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/shlibs.py')
-rw-r--r--giscanner/shlibs.py89
1 files changed, 3 insertions, 86 deletions
diff --git a/giscanner/shlibs.py b/giscanner/shlibs.py
index ec974fa4..1ad75ee6 100644
--- a/giscanner/shlibs.py
+++ b/giscanner/shlibs.py
@@ -25,6 +25,7 @@ import re
import subprocess
from .utils import get_libtool_command, extract_libtool_shlib, which
+from .ccompiler import CCompiler
# For .la files, the situation is easy.
@@ -89,92 +90,8 @@ def _resolve_non_libtool(options, binary, libraries):
binary.args[0] = old_argdir
if os.name == 'nt':
- args = []
- compiler_cmd = os.environ.get('CC', 'cc')
- libsearch = []
-
- # When we are using Visual C++...
- if 'cl.exe' in compiler_cmd or 'cl' in compiler_cmd:
- # The search path of the .lib's on Visual C++
- # is dependent on the LIB environmental variable,
- # so just query for that
- is_msvc = True
- libpath = os.environ.get('LIB')
- libsearch = libpath.split(';')
-
- # Use the dumpbin utility that's included in
- # every Visual C++ installation to find out which
- # DLL the library gets linked to
- args.append('dumpbin.exe')
- args.append('-symbols')
-
- # When we are not using Visual C++ (i.e. we are using GCC)...
- else:
- is_msvc = False
- libtool = get_libtool_command(options)
- if libtool:
- args.append(which(os.environ.get('SHELL', 'sh.exe')))
- args.extend(libtool)
- args.append('--mode=execute')
- # FIXME: it could have prefix (i686-w64-mingw32-dlltool.exe)
- args.extend(['dlltool.exe', '--identify'])
- proc = subprocess.Popen([compiler_cmd, '-print-search-dirs'],
- stdout=subprocess.PIPE)
- o, e = proc.communicate()
- for line in o.splitlines():
- if line.startswith('libraries: '):
- libsearch = line[len('libraries: '):].split(';')
-
- shlibs = []
- not_resolved = []
- for lib in libraries:
- found = False
- candidates = [
- 'lib%s.dll.a' % lib,
- 'lib%s.a' % lib,
- '%s.dll.a' % lib,
- '%s.a' % lib,
- '%s.lib' % lib,
- ]
- for l in libsearch:
- if found:
- break
- if l.startswith('='):
- l = l[1:]
- for c in candidates:
- if found:
- break
- implib = os.path.join(l, c)
- if os.path.exists(implib):
- proc = subprocess.Popen(args + [implib],
- stdout=subprocess.PIPE)
- o, e = proc.communicate()
- for line in o.splitlines():
- if is_msvc:
- # On Visual Studio, dumpbin -symbols something.lib gives the
- # filename of DLL without the '.dll' extension that something.lib
- # links to, in the line that contains
- # __IMPORT_DESCRIPTOR_<dll_filename_that_something.lib_links_to>
-
- if '__IMPORT_DESCRIPTOR_' in line:
- line_tokens = line.split()
- for item in line_tokens:
- if item.startswith('__IMPORT_DESCRIPTOR_'):
- shlibs.append(item[20:] + '.dll')
- found = True
- break
- if found:
- break
- else:
- shlibs.append(line)
- found = True
- break
- if not found:
- not_resolved.append(lib)
- if len(not_resolved) > 0:
- raise SystemExit(
- "ERROR: can't resolve libraries to shared libraries: " +
- ", ".join(not_resolved))
+ cc = CCompiler()
+ shlibs = cc.resolve_windows_libs(libraries, options)
else:
args = []