blob: afa593e3b041348f6721ce1ad593458b5992b60a [file] [log] [blame]
Stefan Reinauerb18f5222015-02-11 01:53:42 +01001#!/bin/sh
2# This file is part of the coreboot project.
3#
4# Copyright 2015 Google Inc.
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; version 2 of the License.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
Martin Roth1ce2ba62016-08-29 15:40:57 -060015# DESCR: Checkpatch on .c, .h, & Kconfig files in the tree
Stefan Reinauerb18f5222015-02-11 01:53:42 +010016
17LC_ALL=C export LC_ALL
Martin Roth1ce2ba62016-08-29 15:40:57 -060018
19# GNU BRE syntax list of files to examine
20INCLUDED_FILES='.*\.[ch]\|Kconfig.*$'
21
22EXCLUDED_DIRS="^payloads/libpayload/util/kconfig\|\
23^payloads/libpayload/curses/PDCurses\|\
Patrick Georgi54867862018-05-30 15:54:08 +020024^util/crossgcc/patches\|\
Nico Huber55e3a6a2019-02-12 12:53:07 +010025^util/inteltool\|\
Martin Roth1ce2ba62016-08-29 15:40:57 -060026^util/kconfig\|\
Nico Huberbfae9a82018-08-19 11:54:57 +020027^util/superiotool\|\
Martin Roth2a063be2017-04-05 21:29:06 -060028^src/vendorcode\|\
29^Documentation"
Martin Roth1ce2ba62016-08-29 15:40:57 -060030
Patrick Georgi54867862018-05-30 15:54:08 +020031# default: test src and util
Martin Roth1ce2ba62016-08-29 15:40:57 -060032if [ "$1" = "" ]; then
33 INCLUDED_DIRS="src util"
Patrick Georgi54867862018-05-30 15:54:08 +020034# special mode: take diff from stdin, but exclude the dirs
35elif [ "$1" = "diff" ]; then
36 args=$( echo $EXCLUDED_DIRS | \
37 sed -e 's,\\|, ,g' -e 's,\^,--exclude=,g' )
Julius Werner0e3f7d42019-03-15 15:37:11 -070038 util/lint/checkpatch.pl --quiet --no-signoff $args -
Patrick Georgi54867862018-05-30 15:54:08 +020039 exit $?
40# Space separated list of directories to test
Martin Roth1ce2ba62016-08-29 15:40:57 -060041else
42 INCLUDED_DIRS="$1"
43fi
44
45# We want word splitting here, so disable the shellcheck warnings
46# shellcheck disable=SC2046,SC2086
47FILELIST=$( git ls-files $INCLUDED_DIRS | \
48 grep $INCLUDED_FILES | \
49 grep -v $EXCLUDED_DIRS )
50
51for FILE in $FILELIST; do
Julius Werner0e3f7d42019-03-15 15:37:11 -070052 util/lint/checkpatch.pl --show-types --file --quiet "$FILE"
Martin Roth1ce2ba62016-08-29 15:40:57 -060053done