59 import re, sys, os, os.path, string
62 sys.stderr.write(
"%s <lib file> <library name> <version> <def file>\n" %
63 os.path.basename(argv[0]))
67 _, libfile, binname, version, deffile = argv
72 cmd =
"DUMPBIN.EXE /SYMBOLS %s" % libfile
74 dumped = os.popen(cmd)
78 linere1 = re.compile(
r"^[^ ]+ +[^ ]+ +SECT[^ ]+ +[^ ]+ +\(\) +External +\| +(\?[^ ]*)(.*)\n")
79 linere2 = re.compile(
r"^[^ ]+ +[^ ]+ +SECT[^ ]+ +[^ ]+ +External +\| +(\?[^?][^ ]*)(.*)\n")
81 exclude = re.compile(
r"deleting destructor[^(]+\(unsigned int\)|anonymous namespace")
84 line = dumped.readline()
88 match = linere1.search(line)
or linere2.search(line)
90 symbol = match.group(1)
92 if exclude.search(args):
95 definitions[symbol] =
None 97 symbols = definitions.keys()
100 print "Output %d symbols." % len(symbols)
102 out = open(deffile,
"w")
103 if string.lower(binname[4:]) ==
".exe":
104 out.write(
"NAME %s\n" % binname)
106 out.write(
"LIBRARY %s\n" % binname)
107 out.write(
"VERSION %s\n" % version)
108 out.write(
"EXPORTS\n")
116 if __name__ ==
"__main__":