gen-def.py 602 B

1234567891011121314151617181920212223242526
  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. try:
  9. lib_file = sys.argv[1]
  10. except:
  11. print('Usage: gen-def.py LIB-FILE')
  12. exit(-1)
  13. print('EXPORTS')
  14. if which('dumpbin'):
  15. dumpbin_cmd = subprocess.run(['dumpbin', '/linkermember:1', lib_file],
  16. stdout=subprocess.PIPE)
  17. pattern = re.compile('\s*[0-9a-fA-F]+ _?(?P<functionname>usrsctp_[^\s]*)')
  18. for line in dumpbin_cmd.stdout.decode('utf-8').splitlines():
  19. match = pattern.match(line)
  20. if match:
  21. print(match.group('functionname'))