Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2020 The Tint Authors. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
Ben Clayton | d9250a5 | 2021-03-10 15:18:39 +0000 | [diff] [blame] | 16 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )" |
| 17 | ROOT_DIR="$( cd "${SCRIPT_DIR}/.." >/dev/null 2>&1 && pwd )" |
| 18 | |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 19 | set -e # fail on error |
| 20 | |
Ben Clayton | bd65d8e | 2021-05-12 15:24:51 +0000 | [diff] [blame] | 21 | if ! command -v cpplint.py &> /dev/null; then |
| 22 | echo "cpplint.py not found on PATH" |
| 23 | exit 1 |
| 24 | fi |
Ben Clayton | d9250a5 | 2021-03-10 15:18:39 +0000 | [diff] [blame] | 25 | |
Ben Clayton | bd65d8e | 2021-05-12 15:24:51 +0000 | [diff] [blame] | 26 | FILTER="-runtime/references" |
Ben Clayton | 17393c1 | 2022-04-07 19:25:14 +0000 | [diff] [blame] | 27 | FILES="`find src/tint -type f` `find src/tint/cmd -type f`" |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 28 | FILES+="`find tools/src -type f` `find src/tint/cmd -type f`" |
Ben Clayton | d9250a5 | 2021-03-10 15:18:39 +0000 | [diff] [blame] | 29 | |
dan sinclair | 2a3d994 | 2022-04-13 16:14:26 +0000 | [diff] [blame] | 30 | # Note, there is currently no verbosity level set for cpplint.py which means |
| 31 | # it will use the default level of 1. This level needs to match what is in the |
| 32 | # PRESUBMIT.py file in order to report the same errors between CQ and Kokoro. |
| 33 | |
Ben Clayton | bd65d8e | 2021-05-12 15:24:51 +0000 | [diff] [blame] | 34 | if command -v go &> /dev/null; then |
Ben Clayton | d9250a5 | 2021-03-10 15:18:39 +0000 | [diff] [blame] | 35 | # Go is installed. Run cpplint in parallel for speed wins |
Ben Clayton | 54f4a21 | 2021-05-14 18:47:33 +0000 | [diff] [blame] | 36 | go run $SCRIPT_DIR/src/cmd/run-parallel/main.go \ |
| 37 | --only-print-failures \ |
| 38 | cpplint.py \ |
| 39 | --root=$ROOT_DIR \ |
| 40 | --filter="$FILTER" \ |
Ben Clayton | d9250a5 | 2021-03-10 15:18:39 +0000 | [diff] [blame] | 41 | $ -- $FILES |
| 42 | else |
Ben Clayton | bd65d8e | 2021-05-12 15:24:51 +0000 | [diff] [blame] | 43 | cpplint.py --root=$ROOT_DIR --filter="$FILTER" $FILES |
Ben Clayton | d9250a5 | 2021-03-10 15:18:39 +0000 | [diff] [blame] | 44 | fi |
| 45 | |