Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 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 | |
| 8 | import os |
| 9 | import subprocess |
| 10 | import sys |
| 11 | |
| 12 | sksllex = sys.argv[1] |
| 13 | clangFormat = sys.argv[2] |
John Stiles | 796e702 | 2020-06-11 19:57:22 -0400 | [diff] [blame] | 14 | fetchClangFormat = sys.argv[3] |
| 15 | src = sys.argv[4] |
| 16 | |
| 17 | exeSuffix = '.exe' if sys.platform.startswith('win') else ''; |
| 18 | |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 19 | try: |
| 20 | subprocess.check_output([sksllex, src + "/sksl/lex/sksl.lex", "Lexer", |
| 21 | "Token", src + "/sksl/SkSLLexer.h", src + |
| 22 | "/sksl/SkSLLexer.cpp"]) |
John Stiles | 796e702 | 2020-06-11 19:57:22 -0400 | [diff] [blame] | 23 | |
| 24 | if not os.path.isfile(clangFormat + exeSuffix): |
| 25 | subprocess.check_call([sys.executable, fetchClangFormat]); |
| 26 | |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 27 | subprocess.check_call(clangFormat + " -i \"" + src + "/sksl/SkSLLexer.h\"", |
| 28 | shell=True) |
| 29 | subprocess.check_call(clangFormat + " -i \"" + src + |
| 30 | "/sksl/SkSLLexer.cpp\"", shell=True) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 31 | except subprocess.CalledProcessError as err: |
| 32 | print("### Lexer error:") |
| 33 | print(err.output) |
| 34 | exit(1) |