blob: 1ffc1ae01a05c01b8e543129b85c2ab429f30bed [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]
John Stilesa25422f2020-06-11 10:50:44 -040014fetchClangFormat = sys.argv[3]
15processors = sys.argv[4:]
16
Ethan Nicholas762466e2017-06-29 10:03:38 -040017for p in processors:
Ethan Nicholas9fb036f2017-07-05 16:19:09 -040018 print("Recompiling " + p + "...")
19 try:
John Stilesa25422f2020-06-11 10:50:44 -040020 if not os.path.isfile(clangFormat):
21 subprocess.check_call(fetchClangFormat)
22
Ethan Nicholas21a9b562019-04-10 12:06:19 -040023 noExt, _ = os.path.splitext(p)
24 head, tail = os.path.split(noExt)
25 targetDir = os.path.join(head, "generated")
John Stilesa25422f2020-06-11 10:50:44 -040026 if not os.path.isdir(targetDir):
Ethan Nicholas21a9b562019-04-10 12:06:19 -040027 os.mkdir(targetDir)
28 target = os.path.join(targetDir, tail)
29 subprocess.check_output([skslc, p, target + ".h"])
Ethan Nicholasb9f6afb2017-07-27 16:02:37 -040030 subprocess.check_call(clangFormat + " --sort-includes=false -i \"" +
Ethan Nicholas21a9b562019-04-10 12:06:19 -040031 target + ".h\"", shell=True)
32 subprocess.check_output([skslc, p, target + ".cpp"])
Ethan Nicholasb9f6afb2017-07-27 16:02:37 -040033 subprocess.check_call(clangFormat + " --sort-includes=false -i \"" +
Ethan Nicholas21a9b562019-04-10 12:06:19 -040034 target + ".cpp\"", shell=True)
Ethan Nicholas9fb036f2017-07-05 16:19:09 -040035 except subprocess.CalledProcessError as err:
36 print("### Error compiling " + p + ":")
37 print(err.output)
38 exit(1)