Home | History | Annotate | Download | only in src
      1 #!/usr/bin/env python
      2 
      3 from __future__ import print_function, division, absolute_import
      4 
      5 import io, os, re, sys
      6 
      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 
     13 headers_content = []
     14 for h in header_paths:
     15 	if h.endswith (".h"):
     16 		with io.open (h, encoding='utf-8') as f: headers_content.append (f.read ())
     17 
     18 symbols = "\n".join (sorted (re.findall (r"^hb_\w+(?= \()", "\n".join (headers_content), re.M)))
     19 
     20 result = symbols if os.environ.get('PLAIN_LIST', '') else """EXPORTS
     21 %s
     22 LIBRARY lib%s-0.dll""" % (symbols, output_file.replace ('.def', ''))
     23 
     24 with open (output_file, "w") as f: f.write (result)
     25