skia2/gn/run_sksllex.py
John Stiles 796e7022ee Reland "Fetch clang-format automatically when compiling .fp files."
This is a reland of a25422faa4

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>
2020-06-12 13:21:41 +00:00

35 lines
1.0 KiB
Python
Executable File

#!/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
sksllex = sys.argv[1]
clangFormat = sys.argv[2]
fetchClangFormat = sys.argv[3]
src = sys.argv[4]
exeSuffix = '.exe' if sys.platform.startswith('win') else '';
try:
subprocess.check_output([sksllex, src + "/sksl/lex/sksl.lex", "Lexer",
"Token", src + "/sksl/SkSLLexer.h", src +
"/sksl/SkSLLexer.cpp"])
if not os.path.isfile(clangFormat + exeSuffix):
subprocess.check_call([sys.executable, fetchClangFormat]);
subprocess.check_call(clangFormat + " -i \"" + src + "/sksl/SkSLLexer.h\"",
shell=True)
subprocess.check_call(clangFormat + " -i \"" + src +
"/sksl/SkSLLexer.cpp\"", shell=True)
except subprocess.CalledProcessError as err:
print("### Lexer error:")
print(err.output)
exit(1)