[Numpy-svn] r6156 - branches/numpy-mingw-w64/numpy/distutils

numpy-svn@scip... numpy-svn@scip...
Fri Dec 19 02:41:42 CST 2008


Author: cdavid
Date: 2008-12-19 02:41:39 -0600 (Fri, 19 Dec 2008)
New Revision: 6156

Modified:
   branches/numpy-mingw-w64/numpy/distutils/mingw32ccompiler.py
Log:
Add a function to generate a .def file from a dll.

Modified: branches/numpy-mingw-w64/numpy/distutils/mingw32ccompiler.py
===================================================================
--- branches/numpy-mingw-w64/numpy/distutils/mingw32ccompiler.py	2008-12-19 08:37:19 UTC (rev 6155)
+++ branches/numpy-mingw-w64/numpy/distutils/mingw32ccompiler.py	2008-12-19 08:41:39 UTC (rev 6156)
@@ -217,6 +217,36 @@
     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
     """



More information about the Numpy-svn mailing list