11
11
from subprocess import Popen , PIPE
12
12
13
13
def gen (dll ,lib ,d ):
14
- output = Popen (["nm " , lib ], stdout = PIPE ).communicate ()[0 ]
14
+ output = Popen (["dumpbin " , "-exports" , dll ], stdout = PIPE ).communicate ()[0 ]
15
15
with open (d , "wb" ) as f :
16
16
f .write (b"EXPORTS\n " )
17
- for line in output .split (b"\r \n " ):
18
- if (re .match (b".* T _|.* I __nm" , line )): #|.* I __imp
19
- line = re .sub (b"^.* T _|^.* I __nm__" , b"" , line ) #|^.* I _
20
- # msvcrt.dll on windows misses secure versions of common CRT functions
21
- if not ("msvcrt.dll" == dll and line .endswith (b"_s" )):
22
- f .write (line + b"\n " )
17
+ lines = output .splitlines ()
18
+ for line in lines [19 :]:
19
+ if line != "" and line [0 ] == " " :
20
+ cols = line .split ()
21
+ if len (cols )== 4 and cols [0 ].isdigit ():
22
+ # msvcrt.dll on windows misses secure versions of common CRT functions
23
+ if not ("msvcrt.dll" == dll and cols [3 ].endswith (b"_s" )):
24
+ f .write (cols [3 ] + b"\n " )
23
25
f .write (str .encode ("LIBRARY %s\n " % dll ))
24
26
25
27
def walk (root ):
@@ -34,7 +36,7 @@ def walk(root):
34
36
if not os .path .exists (d ):
35
37
print ("Working on %s to produce %s\n " % (f , d ))
36
38
lib = "lib%s.dll.a" % name
37
- gen (f , lib , d )
39
+ gen (join ( root , f ) , lib , d )
38
40
Popen (["lib" , "/def:%s" % d , "/name:%s" % f ]).communicate ()
39
41
40
42
def get_parser ():
0 commit comments