Jakub Adam | 47d338c | 2019-07-26 18:49:49 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # gen-def.py usrsctp.lib |
| 4 | import re |
| 5 | import sys |
| 6 | import subprocess |
| 7 | from shutil import which |
| 8 | |
| 9 | try: |
| 10 | lib_file = sys.argv[1] |
| 11 | except: |
| 12 | print('Usage: gen-def.py LIB-FILE') |
| 13 | exit(-1) |
| 14 | |
| 15 | print('EXPORTS') |
| 16 | |
| 17 | if which('dumpbin'): |
| 18 | dumpbin_cmd = subprocess.run(['dumpbin', '/linkermember:1', lib_file], |
| 19 | stdout=subprocess.PIPE) |
| 20 | |
| 21 | pattern = re.compile('\s*[0-9a-fA-F]+ _?(?P<functionname>usrsctp_[^\s]*)') |
| 22 | |
| 23 | for line in dumpbin_cmd.stdout.decode('utf-8').splitlines(): |
| 24 | match = pattern.match(line) |
| 25 | if match: |
| 26 | print(match.group('functionname')) |