Fix shared library build for Windows with MSVC and Meson (#328)
usrsctp-1.dll built with Meson didn't export any symbols. Meson needs
a .def file listing the names of functions to export when creating a
shared library on Windows.
This patch generates usrsctp.def automatically at build time from the
output of "dumpbin /linkermember" run on the static version
of usrsctp lib.
Kudos to Lennart Grahl for help with fixing broken static build.
diff --git a/gen-def.py b/gen-def.py
new file mode 100644
index 0000000..55c0285
--- /dev/null
+++ b/gen-def.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+#
+# gen-def.py usrsctp.lib
+import re
+import sys
+import subprocess
+from shutil import which
+
+try:
+ lib_file = sys.argv[1]
+except:
+ print('Usage: gen-def.py LIB-FILE')
+ exit(-1)
+
+print('EXPORTS')
+
+if which('dumpbin'):
+ dumpbin_cmd = subprocess.run(['dumpbin', '/linkermember:1', lib_file],
+ stdout=subprocess.PIPE)
+
+ pattern = re.compile('\s*[0-9a-fA-F]+ _?(?P<functionname>usrsctp_[^\s]*)')
+
+ for line in dumpbin_cmd.stdout.decode('utf-8').splitlines():
+ match = pattern.match(line)
+ if match:
+ print(match.group('functionname'))