blob: 94a96b646ba0fe2a6b01124c72049fc4766c26c3 [file] [log] [blame]
Dan Sinclair6e581892020-03-02 15:47:43 -05001#!/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 Claytond9250a52021-03-10 15:18:39 +000016SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )"
17ROOT_DIR="$( cd "${SCRIPT_DIR}/.." >/dev/null 2>&1 && pwd )"
18
Dan Sinclair6e581892020-03-02 15:47:43 -050019set -e # fail on error
20
Ben Claytonbd65d8e2021-05-12 15:24:51 +000021if ! command -v cpplint.py &> /dev/null; then
22 echo "cpplint.py not found on PATH"
23 exit 1
24fi
Ben Claytond9250a52021-03-10 15:18:39 +000025
Ben Claytonbd65d8e2021-05-12 15:24:51 +000026FILTER="-runtime/references"
Ben Clayton17393c12022-04-07 19:25:14 +000027FILES="`find src/tint -type f` `find src/tint/cmd -type f`"
Ryan Harrisondbc13af2022-02-21 15:19:07 +000028FILES+="`find tools/src -type f` `find src/tint/cmd -type f`"
Ben Claytond9250a52021-03-10 15:18:39 +000029
dan sinclair2a3d9942022-04-13 16:14:26 +000030# 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 Claytonbd65d8e2021-05-12 15:24:51 +000034if command -v go &> /dev/null; then
Ben Claytond9250a52021-03-10 15:18:39 +000035 # Go is installed. Run cpplint in parallel for speed wins
Ben Clayton54f4a212021-05-14 18:47:33 +000036 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 Claytond9250a52021-03-10 15:18:39 +000041 $ -- $FILES
42else
Ben Claytonbd65d8e2021-05-12 15:24:51 +000043 cpplint.py --root=$ROOT_DIR --filter="$FILTER" $FILES
Ben Claytond9250a52021-03-10 15:18:39 +000044fi
45