blob: 1e6dfd991b7eb9f31a2488cce781350434e18044 [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 Claytond9250a52021-03-10 15:18:39 +000027FILES="`find src -type f` `find samples -type f`"
Ben Clayton54cfa0b2021-07-08 19:35:53 +000028FILES+="`find tools/src -type f` `find samples -type f`"
Ben Claytond9250a52021-03-10 15:18:39 +000029
Ben Claytonbd65d8e2021-05-12 15:24:51 +000030if command -v go &> /dev/null; then
Ben Claytond9250a52021-03-10 15:18:39 +000031 # Go is installed. Run cpplint in parallel for speed wins
Ben Clayton54f4a212021-05-14 18:47:33 +000032 go run $SCRIPT_DIR/src/cmd/run-parallel/main.go \
33 --only-print-failures \
34 cpplint.py \
35 --root=$ROOT_DIR \
36 --filter="$FILTER" \
Ben Claytond9250a52021-03-10 15:18:39 +000037 $ -- $FILES
38else
Ben Claytonbd65d8e2021-05-12 15:24:51 +000039 cpplint.py --root=$ROOT_DIR --filter="$FILTER" $FILES
Ben Claytond9250a52021-03-10 15:18:39 +000040fi
41