Ebrahim Byagowi | 4fc6189 | 2020-04-21 12:19:16 +0430 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | |
Ebrahim Byagowi | a7e82e4 | 2020-07-04 12:04:41 +0430 | [diff] [blame] | 3 | "This tool is intended to be used from meson" |
| 4 | |
Ebrahim Byagowi | 45d9e8d | 2020-07-13 19:25:53 +0430 | [diff] [blame] | 5 | import os, os.path, sys, subprocess, shutil |
Ebrahim Byagowi | 4fc6189 | 2020-04-21 12:19:16 +0430 | [diff] [blame] | 6 | |
Khaled Hosny | 22cbd03 | 2021-09-14 12:34:25 +0200 | [diff] [blame] | 7 | ragel = sys.argv[1] |
Ebrahim Byagowi | 4fc6189 | 2020-04-21 12:19:16 +0430 | [diff] [blame] | 8 | if not ragel: |
Ebrahim Byagowi | 6a2b0ba | 2020-07-04 14:45:15 +0430 | [diff] [blame] | 9 | sys.exit ('You have to install ragel if you are going to develop HarfBuzz itself') |
Ebrahim Byagowi | 4fc6189 | 2020-04-21 12:19:16 +0430 | [diff] [blame] | 10 | |
Ebrahim Byagowi | 785a9a8 | 2020-07-04 02:08:30 +0430 | [diff] [blame] | 11 | if len (sys.argv) < 4: |
Ebrahim Byagowi | 6a2b0ba | 2020-07-04 14:45:15 +0430 | [diff] [blame] | 12 | sys.exit (__doc__) |
Ebrahim Byagowi | 4fc6189 | 2020-04-21 12:19:16 +0430 | [diff] [blame] | 13 | |
Khaled Hosny | 22cbd03 | 2021-09-14 12:34:25 +0200 | [diff] [blame] | 14 | OUTPUT = sys.argv[2] |
| 15 | CURRENT_SOURCE_DIR = sys.argv[3] |
| 16 | INPUT = sys.argv[4] |
Ebrahim Byagowi | e3af529 | 2020-05-23 22:13:32 +0430 | [diff] [blame] | 17 | |
Ebrahim Byagowi | 785a9a8 | 2020-07-04 02:08:30 +0430 | [diff] [blame] | 18 | outdir = os.path.dirname (OUTPUT) |
| 19 | shutil.copy (INPUT, outdir) |
| 20 | rl = os.path.basename (INPUT) |
| 21 | hh = rl.replace ('.rl', '.hh') |
Behdad Esfahbod | 13c6ad9 | 2021-06-12 11:00:19 -0600 | [diff] [blame] | 22 | subprocess.Popen (ragel.split() + ['-e', '-F1', '-o', hh, rl], cwd=outdir).wait () |
Ebrahim Byagowi | e3af529 | 2020-05-23 22:13:32 +0430 | [diff] [blame] | 23 | |
Ebrahim Byagowi | 785a9a8 | 2020-07-04 02:08:30 +0430 | [diff] [blame] | 24 | # copy it also to src/ |
| 25 | shutil.copyfile (os.path.join (outdir, hh), os.path.join (CURRENT_SOURCE_DIR, hh)) |