summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndoni Morales Alastruey <ylatuya@gmail.com>2013-05-10 16:21:55 (GMT)
committerAndoni Morales Alastruey <ylatuya@gmail.com>2013-05-10 16:21:55 (GMT)
commitfef08bb8738f0690a199218a282af7ad8cd1f0da (patch)
tree026f4b846c4e08991dc1ba99e8527cd225a5086c
parent626b3e1b11313c903dfe11bde68504ca8931ba8e (diff)
downloadcerbero-fef08bb8738f0690a199218a282af7ad8cd1f0da.tar.gz
cerbero-fef08bb8738f0690a199218a282af7ad8cd1f0da.tar.xz
genlib: use lib.exe instead of dlltool when available
-rw-r--r--cerbero/build/recipe.py1
-rw-r--r--cerbero/ide/vs/genlib.py32
2 files changed, 30 insertions, 3 deletions
diff --git a/cerbero/build/recipe.py b/cerbero/build/recipe.py
index 4a49b3e..b6d27c7 100644
--- a/cerbero/build/recipe.py
+++ b/cerbero/build/recipe.py
@@ -202,6 +202,7 @@ class Recipe(FilesProvider):
try:
implib = genlib.create(
os.path.join(self.config.prefix, dllpath),
+ self.config.target_arch,
os.path.join(self.config.prefix, 'lib'))
logging.debug('Created %s' % implib)
except:
diff --git a/cerbero/ide/vs/genlib.py b/cerbero/ide/vs/genlib.py
index 40333f0..f542ad3 100644
--- a/cerbero/ide/vs/genlib.py
+++ b/cerbero/ide/vs/genlib.py
@@ -18,7 +18,8 @@
import os
-from cerbero.utils import shell
+from cerbero.config import Architecture
+from cerbero.utils import shell, to_unixpath
class GenLib(object):
@@ -29,8 +30,9 @@ class GenLib(object):
'''
DLLTOOL_TPL = '$DLLTOOL -d %s -l %s -D %s'
+ LIB_TPL = '%s /DEF:%s /OUT:%s /MACHINE:%s'
- def create(self, dllpath, outputdir=None):
+ def create(self, dllpath, arch, outputdir=None):
bindir, dllname = os.path.split(dllpath)
if outputdir is None:
outputdir = bindir
@@ -48,5 +50,29 @@ class GenLib(object):
implib = '%s.lib' % libname[3:]
# Create the import library
- shell.call(self.DLLTOOL_TPL % (defname, implib, dllname), outputdir)
+ vc_path = self._get_vc_tools_path()
+
+ # Prefer LIB.exe over dlltool:
+ # http://sourceware.org/bugzilla/show_bug.cgi?id=12633
+ if vc_path is not None:
+ # Spaces msys and shell are a beautiful combination
+ lib_path = to_unixpath(os.path.join(vc_path, 'lib.exe'))
+ lib_path = lib_path.replace('\\', '/')
+ lib_path = lib_path.replace('(', '\\\(').replace(')', '\\\)')
+ lib_path = lib_path.replace(' ', '\\\\ ')
+ if arch == Architecture.X86:
+ arch = 'x86'
+ else:
+ arch = 'x64'
+ shell.call(self.LIB_TPL % (lib_path, defname, implib, arch), outputdir)
+ else:
+ shell.call(self.DLLTOOL_TPL % (defname, implib, dllname), outputdir)
return os.path.join(outputdir, implib)
+
+ def _get_vc_tools_path(self):
+ if 'VS100COMNTOOLS' in os.environ:
+ path = os.path.join(os.environ['VS100COMNTOOLS'], '..', '..',
+ 'VC', 'bin', 'amd64')
+ if os.path.exists (path):
+ return path
+ return None