Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright 2017 Google Inc. |
| 4 | # |
| 5 | # Use of this source code is governed by a BSD-style license that can be |
| 6 | # found in the LICENSE file. |
| 7 | |
| 8 | import os |
| 9 | import subprocess |
| 10 | import sys |
| 11 | |
| 12 | skslc = sys.argv[1] |
Ethan Nicholas | b9f6afb | 2017-07-27 16:02:37 -0400 | [diff] [blame] | 13 | clangFormat = sys.argv[2] |
| 14 | processors = sys.argv[3:] |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 15 | for p in processors: |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 16 | print("Recompiling " + p + "...") |
| 17 | try: |
Ethan Nicholas | 21a9b56 | 2019-04-10 12:06:19 -0400 | [diff] [blame] | 18 | noExt, _ = os.path.splitext(p) |
| 19 | head, tail = os.path.split(noExt) |
| 20 | targetDir = os.path.join(head, "generated") |
| 21 | if not os.path.exists(targetDir): |
| 22 | os.mkdir(targetDir) |
| 23 | target = os.path.join(targetDir, tail) |
| 24 | subprocess.check_output([skslc, p, target + ".h"]) |
Ethan Nicholas | b9f6afb | 2017-07-27 16:02:37 -0400 | [diff] [blame] | 25 | subprocess.check_call(clangFormat + " --sort-includes=false -i \"" + |
Ethan Nicholas | 21a9b56 | 2019-04-10 12:06:19 -0400 | [diff] [blame] | 26 | target + ".h\"", shell=True) |
| 27 | subprocess.check_output([skslc, p, target + ".cpp"]) |
Ethan Nicholas | b9f6afb | 2017-07-27 16:02:37 -0400 | [diff] [blame] | 28 | subprocess.check_call(clangFormat + " --sort-includes=false -i \"" + |
Ethan Nicholas | 21a9b56 | 2019-04-10 12:06:19 -0400 | [diff] [blame] | 29 | target + ".cpp\"", shell=True) |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 30 | except subprocess.CalledProcessError as err: |
| 31 | print("### Error compiling " + p + ":") |
| 32 | print(err.output) |
| 33 | exit(1) |