harfbuzz/src/gen-def.py

34 lines
965 B
Python
Raw Permalink Normal View History

#!/usr/bin/env python3
2020-05-28 12:31:15 +02:00
"usage: gen-def.py harfbuzz.def hb.h [hb-blob.h hb-buffer.h ...]"
2020-05-28 21:41:19 +02:00
import os, re, sys
if len (sys.argv) < 3:
2020-05-28 12:31:15 +02:00
sys.exit(__doc__)
output_file = sys.argv[1]
header_paths = sys.argv[2:]
headers_content = []
for h in header_paths:
if h.endswith (".h"):
2020-05-28 21:41:19 +02:00
with open (h, encoding='utf-8') as f: headers_content.append (f.read ())
symbols = sorted (re.findall (r"^hb_\w+(?= \()", "\n".join (headers_content), re.M))
2020-04-20 22:43:13 +02:00
if '--experimental-api' not in sys.argv:
# Move these to harfbuzz-sections.txt when got stable
experimental_symbols = \
2023-03-01 22:16:08 +01:00
"""hb_shape_justify
hb_subset_repack_or_fail
hb_subset_input_override_name_table
""".splitlines ()
symbols = [x for x in symbols if x not in experimental_symbols]
symbols = "\n".join (symbols)
result = symbols if os.getenv ('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)