1#!/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] 13clangFormat = sys.argv[2] 14processors = sys.argv[3:] 15for p in processors: 16 print("Recompiling " + p + "...") 17 try: 18 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"]) 25 subprocess.check_call(clangFormat + " --sort-includes=false -i \"" + 26 target + ".h\"", shell=True) 27 subprocess.check_output([skslc, p, target + ".cpp"]) 28 subprocess.check_call(clangFormat + " --sort-includes=false -i \"" + 29 target + ".cpp\"", shell=True) 30 except subprocess.CalledProcessError as err: 31 print("### Error compiling " + p + ":") 32 print(err.output) 33 exit(1) 34