Reland "Fetch clang-format automatically when compiling .fp files."
This is a reland of a25422faa462e8cfb00af1a3818547abbbb9c7f9
Original change's description:
> Fetch clang-format automatically when compiling .fp files.
>
> On a freshly fetched repo, setting `skia_compile_processors = true` will
> fail to compile because clang-format is missing from the bin directory.
> This CL automatically runs fetch-clang-format for you when clang-format
> is absent.
>
> Change-Id: Ieeb359176072e92ca235316c820310333732f608
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/295780
> Reviewed-by: Mike Klein <mtklein@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>
Change-Id: Ib397716771f742f192ebd6ed7ec0a9915b2400c5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/295956
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
diff --git a/gn/compile_processors.py b/gn/compile_processors.py
index 922b653..c006532 100755
--- a/gn/compile_processors.py
+++ b/gn/compile_processors.py
@@ -11,14 +11,21 @@
skslc = sys.argv[1]
clangFormat = sys.argv[2]
-processors = sys.argv[3:]
+fetchClangFormat = sys.argv[3]
+processors = sys.argv[4:]
+
+exeSuffix = '.exe' if sys.platform.startswith('win') else '';
+
for p in processors:
print("Recompiling " + p + "...")
try:
+ if not os.path.isfile(clangFormat + exeSuffix):
+ subprocess.check_call([sys.executable, fetchClangFormat]);
+
noExt, _ = os.path.splitext(p)
head, tail = os.path.split(noExt)
targetDir = os.path.join(head, "generated")
- if not os.path.exists(targetDir):
+ if not os.path.isdir(targetDir):
os.mkdir(targetDir)
target = os.path.join(targetDir, tail)
subprocess.check_output([skslc, p, target + ".h"])