Bug 769607 - dependentlibs.py depends on dumpbin r=glandium

This commit is contained in:
Jacek Caban 2012-07-10 14:29:53 +02:00
Родитель 278d6fb643
Коммит f202c8637b
1 изменённых файлов: 15 добавлений и 1 удалений

Просмотреть файл

@ -17,7 +17,11 @@ TOOLCHAIN_PREFIX = ''
def dependentlibs_dumpbin(lib):
'''Returns the list of dependencies declared in the given DLL'''
proc = subprocess.Popen(['dumpbin', '-imports', lib], stdout = subprocess.PIPE)
try:
proc = subprocess.Popen(['dumpbin', '-imports', lib], stdout = subprocess.PIPE)
except OSError:
# dumpbin is missing, probably mingw compilation. Try using objdump.
return dependentlibs_mingw_objdump(lib)
deps = []
for line in proc.stdout:
# Each line containing an imported library name starts with 4 spaces
@ -27,6 +31,16 @@ def dependentlibs_dumpbin(lib):
proc.wait()
return deps
def dependentlibs_mingw_objdump(lib):
proc = subprocess.Popen(['objdump', '-x', lib], stdout = subprocess.PIPE)
deps = []
for line in proc.stdout:
match = re.match('\tDLL Name: (\S+)', line)
if match:
deps.append(match.group(1))
proc.wait()
return deps
def dependentlibs_readelf(lib):
'''Returns the list of dependencies declared in the given ELF .so'''
proc = subprocess.Popen([TOOLCHAIN_PREFIX + 'readelf', '-d', lib], stdout = subprocess.PIPE)