2017-06-29 14:03:38 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
|
|
|
# Copyright 2017 Google Inc.
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
|
|
|
skslc = sys.argv[1]
|
2017-07-27 20:02:37 +00:00
|
|
|
clangFormat = sys.argv[2]
|
2020-06-11 23:57:22 +00:00
|
|
|
fetchClangFormat = sys.argv[3]
|
|
|
|
processors = sys.argv[4:]
|
|
|
|
|
|
|
|
exeSuffix = '.exe' if sys.platform.startswith('win') else '';
|
|
|
|
|
2017-06-29 14:03:38 +00:00
|
|
|
for p in processors:
|
2017-07-05 20:19:09 +00:00
|
|
|
print("Recompiling " + p + "...")
|
|
|
|
try:
|
2020-06-11 23:57:22 +00:00
|
|
|
if not os.path.isfile(clangFormat + exeSuffix):
|
|
|
|
subprocess.check_call([sys.executable, fetchClangFormat]);
|
|
|
|
|
2019-04-10 16:06:19 +00:00
|
|
|
noExt, _ = os.path.splitext(p)
|
|
|
|
head, tail = os.path.split(noExt)
|
|
|
|
targetDir = os.path.join(head, "generated")
|
2020-06-11 23:57:22 +00:00
|
|
|
if not os.path.isdir(targetDir):
|
2019-04-10 16:06:19 +00:00
|
|
|
os.mkdir(targetDir)
|
|
|
|
target = os.path.join(targetDir, tail)
|
|
|
|
subprocess.check_output([skslc, p, target + ".h"])
|
2017-07-27 20:02:37 +00:00
|
|
|
subprocess.check_call(clangFormat + " --sort-includes=false -i \"" +
|
2019-04-10 16:06:19 +00:00
|
|
|
target + ".h\"", shell=True)
|
|
|
|
subprocess.check_output([skslc, p, target + ".cpp"])
|
2017-07-27 20:02:37 +00:00
|
|
|
subprocess.check_call(clangFormat + " --sort-includes=false -i \"" +
|
2019-04-10 16:06:19 +00:00
|
|
|
target + ".cpp\"", shell=True)
|
2017-07-05 20:19:09 +00:00
|
|
|
except subprocess.CalledProcessError as err:
|
|
|
|
print("### Error compiling " + p + ":")
|
|
|
|
print(err.output)
|
|
|
|
exit(1)
|