Ebrahim Byagowi | 0080614 | 2018-01-19 01:12:31 +0330 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
Ebrahim Byagowi | cab2c2c | 2018-03-29 12:48:47 +0430 | [diff] [blame] | 3 | from __future__ import print_function, division, absolute_import |
Ebrahim Byagowi | 0080614 | 2018-01-19 01:12:31 +0330 | [diff] [blame] | 4 | |
| 5 | import io, os, re, sys |
| 6 | |
Cosimo Lupo | e3a931e | 2018-07-09 18:11:29 +0100 | [diff] [blame] | 7 | if len (sys.argv) < 3: |
| 8 | sys.exit("usage: gen-def.py harfbuzz.def hb.h [hb-blob.h hb-buffer.h ...]") |
| 9 | |
| 10 | output_file = sys.argv[1] |
| 11 | header_paths = sys.argv[2:] |
| 12 | |
Ebrahim Byagowi | 0080614 | 2018-01-19 01:12:31 +0330 | [diff] [blame] | 13 | headers_content = [] |
Cosimo Lupo | e3a931e | 2018-07-09 18:11:29 +0100 | [diff] [blame] | 14 | for h in header_paths: |
Ebrahim Byagowi | 0080614 | 2018-01-19 01:12:31 +0330 | [diff] [blame] | 15 | if h.endswith (".h"): |
Ebrahim Byagowi | 8d1b408 | 2018-03-17 01:05:03 +0330 | [diff] [blame] | 16 | with io.open (h, encoding='utf-8') as f: headers_content.append (f.read ()) |
Ebrahim Byagowi | 0080614 | 2018-01-19 01:12:31 +0330 | [diff] [blame] | 17 | |
Ebrahim Byagowi | a9b650d | 2018-02-12 15:10:13 +0330 | [diff] [blame] | 18 | result = """EXPORTS |
| 19 | %s |
| 20 | LIBRARY lib%s-0.dll""" % ( |
| 21 | "\n".join (sorted (re.findall (r"^hb_\w+(?= \()", "\n".join (headers_content), re.M))), |
Cosimo Lupo | e3a931e | 2018-07-09 18:11:29 +0100 | [diff] [blame] | 22 | output_file.replace ('.def', '') |
Ebrahim Byagowi | a9b650d | 2018-02-12 15:10:13 +0330 | [diff] [blame] | 23 | ) |
Ebrahim Byagowi | 0080614 | 2018-01-19 01:12:31 +0330 | [diff] [blame] | 24 | |
Cosimo Lupo | e3a931e | 2018-07-09 18:11:29 +0100 | [diff] [blame] | 25 | with open (output_file, "w") as f: f.write (result) |