xref: /aosp_15_r20/external/skia/gn/run_sksllex.py (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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
12sksllex = sys.argv[1]
13clangFormat = sys.argv[2]
14fetchClangFormat = sys.argv[3]
15src = sys.argv[4]
16
17exeSuffix = '.exe' if sys.platform.startswith('win') else '';
18
19try:
20    subprocess.check_output([sksllex, src + "/sksl/lex/sksl.lex", "Lexer",
21                             "Token", src + "/sksl/SkSLLexer.h", src +
22                             "/sksl/SkSLLexer.cpp"])
23
24    if not os.path.isfile(clangFormat + exeSuffix):
25        subprocess.check_call([sys.executable, fetchClangFormat]);
26
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)
31except subprocess.CalledProcessError as err:
32    print("### Lexer error:")
33    print(err.output)
34    exit(1)
35