From e9d5604aebc5e04a299bbb93dd9d6865a383974f Mon Sep 17 00:00:00 2001 From: David Cournapeau Date: Fri, 19 Dec 2008 08:41:39 +0000 Subject: Add a function to generate a .def file from a dll. --- numpy/distutils/mingw32ccompiler.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'numpy/distutils/mingw32ccompiler.py') diff --git a/numpy/distutils/mingw32ccompiler.py b/numpy/distutils/mingw32ccompiler.py index af0ac2a16..5edd0b33a 100644 --- a/numpy/distutils/mingw32ccompiler.py +++ b/numpy/distutils/mingw32ccompiler.py @@ -217,6 +217,36 @@ def dump_table(dll): st = subprocess.Popen(["objdump.exe", "-p", dll], stdout=subprocess.PIPE) return st.stdout.readlines() +def generate_def(dll, dfile): + """Given a dll file location, get all its exported symbols and dump them + into the given def file. + + The .def file will be overwritten""" + dump = dump_table(dll) + for i in range(len(dump)): + if TABLE.match(dump[i]): + break + + if i == len(dump): + raise ValueError("Symbol table not found") + + syms = [] + for j in range(i, len(dump)): + m = table.match(lines[j]) + if m: + syms.append((int(m.group(1).strip()), m.group(2))) + else: + break + + d = open(deffile, 'w') + d.write('LIBRARY %s\n' % dllname) + d.write(';CODE PRELOAD MOVEABLE DISCARDABLE\n') + d.write(';DATA PRELOAD SINGLE\n') + d.write('\nEXPORTS\n') + for s in syms: + d.write('@%d %s\n' % (s[0], s[1])) + d.close() + def build_import_library(): """ Build the import libraries for Mingw32-gcc on Windows """ -- cgit v1.2.1