Imported Upstream version 2.6.7
[platform/upstream/harfbuzz.git] / src / gen-def.py
1 #!/usr/bin/env python3
2
3 "usage: gen-def.py harfbuzz.def hb.h [hb-blob.h hb-buffer.h ...]"
4
5 import os, re, sys
6
7 if len (sys.argv) < 3:
8         sys.exit(__doc__)
9
10 output_file = sys.argv[1]
11 header_paths = sys.argv[2:]
12
13 headers_content = []
14 for h in header_paths:
15         if h.endswith (".h"):
16                 with open (h, encoding='utf-8') as f: headers_content.append (f.read ())
17
18 symbols = sorted (re.findall (r"^hb_\w+(?= \()", "\n".join (headers_content), re.M))
19 if '--experimental-api' not in sys.argv:
20         # Move these to harfbuzz-sections.txt when got stable
21         experimental_symbols = \
22 """hb_font_draw_glyph
23 hb_draw_funcs_t
24 hb_draw_close_path_func_t
25 hb_draw_cubic_to_func_t
26 hb_draw_line_to_func_t
27 hb_draw_move_to_func_t
28 hb_draw_quadratic_to_func_t
29 hb_draw_funcs_create
30 hb_draw_funcs_destroy
31 hb_draw_funcs_is_immutable
32 hb_draw_funcs_make_immutable
33 hb_draw_funcs_reference
34 hb_draw_funcs_set_close_path_func
35 hb_draw_funcs_set_cubic_to_func
36 hb_draw_funcs_set_line_to_func
37 hb_draw_funcs_set_move_to_func
38 hb_draw_funcs_set_quadratic_to_func
39 hb_font_get_var_coords_design
40 hb_ot_layout_closure_lookups
41 hb_ot_layout_closure_features""".splitlines ()
42         symbols = [x for x in symbols if x not in experimental_symbols]
43 symbols = "\n".join (symbols)
44
45 result = symbols if os.environ.get('PLAIN_LIST', '') else """EXPORTS
46 %s
47 LIBRARY lib%s-0.dll""" % (symbols, output_file.replace ('src/', '').replace ('.def', ''))
48
49 with open (output_file, "w") as f: f.write (result)