blob: c006532df4f38a9255c86a2399e49aadc17efc4a [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 Stiles796e7022020-06-11 19:57:22 -040014fetchClangFormat = sys.argv[3]
15processors = sys.argv[4:]
16
17exeSuffix = '.exe' if sys.platform.startswith('win') else '';
18
Ethan Nicholas762466e2017-06-29 10:03:38 -040019for p in processors:
Ethan Nicholas9fb036f2017-07-05 16:19:09 -040020 print("Recompiling " + p + "...")
21 try:
John Stiles796e7022020-06-11 19:57:22 -040022 if not os.path.isfile(clangFormat + exeSuffix):
23 subprocess.check_call([sys.executable, fetchClangFormat]);
24
Ethan Nicholas21a9b562019-04-10 12:06:19 -040025 noExt, _ = os.path.splitext(p)
26 head, tail = os.path.split(noExt)
27 targetDir = os.path.join(head, "generated")
John Stiles796e7022020-06-11 19:57:22 -040028 if not os.path.isdir(targetDir):
Ethan Nicholas21a9b562019-04-10 12:06:19 -040029 os.mkdir(targetDir)
30 target = os.path.join(targetDir, tail)
31 subprocess.check_output([skslc, p, target + ".h"])
Ethan Nicholasb9f6afb2017-07-27 16:02:37 -040032 subprocess.check_call(clangFormat + " --sort-includes=false -i \"" +
Ethan Nicholas21a9b562019-04-10 12:06:19 -040033 target + ".h\"", shell=True)
34 subprocess.check_output([skslc, p, target + ".cpp"])
Ethan Nicholasb9f6afb2017-07-27 16:02:37 -040035 subprocess.check_call(clangFormat + " --sort-includes=false -i \"" +
Ethan Nicholas21a9b562019-04-10 12:06:19 -040036 target + ".cpp\"", shell=True)
Ethan Nicholas9fb036f2017-07-05 16:19:09 -040037 except subprocess.CalledProcessError as err:
38 print("### Error compiling " + p + ":")
39 print(err.output)
40 exit(1)