3 import os, re, sys, subprocess, shutil, tempfile
5 os.chdir (os.path.dirname (__file__))
8 ragel_sources = [x for x in os.listdir ('.') if x.endswith ('.rl')]
10 ragel_sources = sys.argv[2:]
12 ragel = shutil.which ('ragel')
15 print ('You have to install ragel if you are going to develop HarfBuzz itself')
18 if not len (ragel_sources):
21 tempdir = tempfile.mkdtemp ()
23 for rl in ragel_sources:
24 hh = rl.replace ('.rl', '.hh')
25 shutil.copy (rl, tempdir)
26 # writing to stdout has some complication on Windows
27 subprocess.Popen ([ragel, '-e', '-F1', '-o', hh, rl], cwd=tempdir).wait ()
29 generated_path = os.path.join (tempdir, hh)
30 with open (generated_path, "rb") as temp_file:
31 generated = temp_file.read()
33 with open (hh, "rb") as current_file:
34 current = current_file.read()
36 # overwrite only if is changed
37 if generated != current:
38 shutil.copyfile (generated_path, hh)
40 shutil.rmtree (tempdir)