John Stiles | d836f84 | 2020-09-14 10:21:44 -0400 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright 2020 Google LLC |
| 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] |
| 13 | inputs = sys.argv[2:] |
| 14 | |
| 15 | for input in inputs: |
| 16 | try: |
| 17 | noExt, ext = os.path.splitext(input) |
| 18 | head, tail = os.path.split(noExt) |
| 19 | targetDir = os.path.join(head, "golden") |
| 20 | if not os.path.isdir(targetDir): |
| 21 | os.mkdir(targetDir) |
| 22 | target = os.path.join(targetDir, tail) |
| 23 | if ext == ".fp": |
| 24 | subprocess.check_output([skslc, input, target + ".h"], |
| 25 | stderr=subprocess.STDOUT) |
| 26 | subprocess.check_output([skslc, input, target + ".cpp"], |
| 27 | stderr=subprocess.STDOUT) |
| 28 | elif ext == ".sksl": |
| 29 | subprocess.check_output([skslc, input, target + ".glsl"], |
| 30 | stderr=subprocess.STDOUT) |
| 31 | else: |
| 32 | print("### Unrecognized file type for " + input + ", skipped") |
| 33 | |
| 34 | except subprocess.CalledProcessError as err: |
| 35 | print("### Error compiling " + input + ":") |
| 36 | print(err.output) |
| 37 | exit(1) |