blob: 922b6539de1fe94ecea80e78b97661fd9e929f80 [file] [log] [blame]
Ethan Nicholas762466e2017-06-29 10:03:38 -04001#!/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
8import os
9import subprocess
10import sys
11
12skslc = sys.argv[1]
Ethan Nicholasb9f6afb2017-07-27 16:02:37 -040013clangFormat = sys.argv[2]
14processors = sys.argv[3:]
Ethan Nicholas762466e2017-06-29 10:03:38 -040015for p in processors:
Ethan Nicholas9fb036f2017-07-05 16:19:09 -040016 print("Recompiling " + p + "...")
17 try:
Ethan Nicholas21a9b562019-04-10 12:06:19 -040018 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 Nicholasb9f6afb2017-07-27 16:02:37 -040025 subprocess.check_call(clangFormat + " --sort-includes=false -i \"" +
Ethan Nicholas21a9b562019-04-10 12:06:19 -040026 target + ".h\"", shell=True)
27 subprocess.check_output([skslc, p, target + ".cpp"])
Ethan Nicholasb9f6afb2017-07-27 16:02:37 -040028 subprocess.check_call(clangFormat + " --sort-includes=false -i \"" +
Ethan Nicholas21a9b562019-04-10 12:06:19 -040029 target + ".cpp\"", shell=True)
Ethan Nicholas9fb036f2017-07-05 16:19:09 -040030 except subprocess.CalledProcessError as err:
31 print("### Error compiling " + p + ":")
32 print(err.output)
33 exit(1)