blob: 8b92efae9dedc9ca529e66ece38ddd7893580bc7 [file] [log] [blame]
John Stilesd836f842020-09-14 10:21:44 -04001#!/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
8import os
9import subprocess
10import sys
11
12skslc = sys.argv[1]
13inputs = sys.argv[2:]
14
15for 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)