3 # Copied from https://github.com/xantares/mingw-ldd/blob/master/mingw-ldd.py
4 # Modified to point to right prefix location on Fedora.
6 # WTFPL - Do What the Fuck You Want to Public License
7 from __future__ import print_function
13 def get_dependency(filename):
15 pe = pefile.PE(filename)
16 for imp in pe.DIRECTORY_ENTRY_IMPORT:
17 deps.append(imp.dll.decode())
21 def dep_tree(root, prefix=None):
24 #print('Arch =', arch)
25 prefix = '/usr/'+arch+'-w64-mingw32/sys-root/mingw/bin'
26 #print('Using default prefix', prefix)
29 def dep_tree_impl(root, prefix):
30 for dll in get_dependency(root):
33 full_path = os.path.join(prefix, dll)
34 if os.path.exists(full_path):
35 dep_dlls[dll] = full_path
36 dep_tree_impl(full_path, prefix=prefix)
38 dep_dlls[dll] = 'not found'
40 dep_tree_impl(root, prefix)
44 def get_arch(filename):
45 type2arch= {pefile.OPTIONAL_HEADER_MAGIC_PE: 'i686',
46 pefile.OPTIONAL_HEADER_MAGIC_PE_PLUS: 'x86_64'}
47 pe = pefile.PE(filename)
49 return type2arch[pe.PE_TYPE]
51 sys.stderr.write('Error: unknown architecture')
54 if __name__ == '__main__':
55 filename = sys.argv[1]
56 for dll, full_path in dep_tree(filename).items():
57 print(' ' * 7, dll, '=>', full_path)