summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Cournapeau <cournape@gmail.com>2008-12-19 08:41:39 +0000
committerDavid Cournapeau <cournape@gmail.com>2008-12-19 08:41:39 +0000
commite9d5604aebc5e04a299bbb93dd9d6865a383974f (patch)
tree28a92f3ee7ab794a17eee3cc03d4c7152ec74d97
parentf7ad1d4d90b20a597c92a4685a5b3a4e4b331956 (diff)
downloadnumpy-e9d5604aebc5e04a299bbb93dd9d6865a383974f.tar.gz
Add a function to generate a .def file from a dll.
-rw-r--r--numpy/distutils/mingw32ccompiler.py30
1 files changed, 30 insertions, 0 deletions
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
"""