(root)/
harfbuzz-8.3.0/
src/
gen-harfbuzzcc.py
       1  #!/usr/bin/env python3
       2  
       3  "This tool is intended to be used from meson"
       4  
       5  import os, sys, shutil
       6  
       7  if len (sys.argv) < 3:
       8  	sys.exit (__doc__)
       9  
      10  OUTPUT = sys.argv[1]
      11  CURRENT_SOURCE_DIR = sys.argv[2]
      12  
      13  # make sure input files are unique
      14  sources = sorted(set(sys.argv[3:]))
      15  
      16  with open (OUTPUT, "wb") as f:
      17  	f.write ("".join ('#include "{}"\n'.format (os.path.relpath (os.path.abspath (x), CURRENT_SOURCE_DIR)) for x in sources if x.endswith (".cc")).encode ())
      18  
      19  # copy it also to the source tree, but only if it has changed
      20  baseline_filename = os.path.join (CURRENT_SOURCE_DIR, os.path.basename (OUTPUT))
      21  with open(baseline_filename, "rb") as baseline:
      22  	with open(OUTPUT, "rb") as generated:
      23  		if baseline.read() != generated.read():
      24  			shutil.copyfile (OUTPUT, baseline_filename)