1#!/usr/local/bin/python3.8
2
3"This tool is intended to be used from meson"
4
5import os, os.path, sys, subprocess, shutil
6
7ragel = sys.argv[1]
8if not ragel:
9	sys.exit ('You have to install ragel if you are going to develop HarfBuzz itself')
10
11if len (sys.argv) < 4:
12	sys.exit (__doc__)
13
14OUTPUT = sys.argv[2]
15CURRENT_SOURCE_DIR = sys.argv[3]
16INPUT = sys.argv[4]
17
18outdir = os.path.dirname (OUTPUT)
19shutil.copy (INPUT, outdir)
20rl = os.path.basename (INPUT)
21hh = rl.replace ('.rl', '.hh')
22subprocess.Popen (ragel.split() + ['-e', '-F1', '-o', hh, rl], cwd=outdir).wait ()
23
24# copy it also to src/
25shutil.copyfile (os.path.join (outdir, hh), os.path.join (CURRENT_SOURCE_DIR, hh))
26