Hash :
d230a020
Author :
Date :
2018-11-12T19:41:39
meson: generate .def file for MSVC symbol export on the fly Fix symbol export with MSVC when features are disabled, such as GLib. We need to generate the list of exported symbols on the fly to make sure we only export symbols that are actually available. Needs some minor modifications to the gen-def.py script: - accept header list also via command line args; we can't pass things to a configure_file() command via the environment in Meson. - strip any leading 'src/' from library filename. This might be there because in Meson the script might be called from the top-level directory and not the current source directory. Remove .def files again which had been checked in for earlier versions of the Meson port.
#!/usr/bin/env python3
import io, os, re, sys
if len (sys.argv) < 3:
sys.exit("usage: gen-def.py harfbuzz.def hb.h [hb-blob.h hb-buffer.h ...]")
output_file = sys.argv[1]
header_paths = sys.argv[2:]
headers_content = []
for h in header_paths:
if h.endswith (".h"):
with io.open (h, encoding='utf-8') as f: headers_content.append (f.read ())
symbols = "\n".join (sorted (re.findall (r"^hb_\w+(?= \()", "\n".join (headers_content), re.M)))
result = symbols if os.environ.get('PLAIN_LIST', '') else """EXPORTS
%s
LIBRARY lib%s-0.dll""" % (symbols, output_file.replace ('src/', '').replace ('.def', ''))
with open (output_file, "w") as f: f.write (result)