blob: ba39eaae586f711e0d3328a20d86c4a73da0d484 [file] [log] [blame]
Ebrahim Byagowi00806142018-01-19 01:12:31 +03301#!/usr/bin/env python
2
Ebrahim Byagowicab2c2c2018-03-29 12:48:47 +04303from __future__ import print_function, division, absolute_import
Ebrahim Byagowi00806142018-01-19 01:12:31 +03304
5import io, os, re, sys
6
Cosimo Lupoe3a931e2018-07-09 18:11:29 +01007if len (sys.argv) < 3:
8 sys.exit("usage: gen-def.py harfbuzz.def hb.h [hb-blob.h hb-buffer.h ...]")
9
10output_file = sys.argv[1]
11header_paths = sys.argv[2:]
12
Ebrahim Byagowi00806142018-01-19 01:12:31 +033013headers_content = []
Cosimo Lupoe3a931e2018-07-09 18:11:29 +010014for h in header_paths:
Ebrahim Byagowi00806142018-01-19 01:12:31 +033015 if h.endswith (".h"):
Ebrahim Byagowi8d1b4082018-03-17 01:05:03 +033016 with io.open (h, encoding='utf-8') as f: headers_content.append (f.read ())
Ebrahim Byagowi00806142018-01-19 01:12:31 +033017
Ebrahim Byagowia9b650d2018-02-12 15:10:13 +033018result = """EXPORTS
19%s
20LIBRARY lib%s-0.dll""" % (
21 "\n".join (sorted (re.findall (r"^hb_\w+(?= \()", "\n".join (headers_content), re.M))),
Cosimo Lupoe3a931e2018-07-09 18:11:29 +010022 output_file.replace ('.def', '')
Ebrahim Byagowia9b650d2018-02-12 15:10:13 +033023)
Ebrahim Byagowi00806142018-01-19 01:12:31 +033024
Cosimo Lupoe3a931e2018-07-09 18:11:29 +010025with open (output_file, "w") as f: f.write (result)