blob: 9111c698c36524a1cb261a96a422d4dacb71d635 [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 Byagowi7170e352018-10-29 13:11:01 +033018symbols = "\n".join (sorted (re.findall (r"^hb_\w+(?= \()", "\n".join (headers_content), re.M)))
19
20result = symbols if os.environ.get('PLAIN_LIST', '') else """EXPORTS
Ebrahim Byagowia9b650d2018-02-12 15:10:13 +033021%s
Ebrahim Byagowi7170e352018-10-29 13:11:01 +033022LIBRARY lib%s-0.dll""" % (symbols, output_file.replace ('.def', ''))
Ebrahim Byagowi00806142018-01-19 01:12:31 +033023
Cosimo Lupoe3a931e2018-07-09 18:11:29 +010024with open (output_file, "w") as f: f.write (result)