blob: f78454198f46c037e53cefb379303779a008eaee [file] [log] [blame]
Stefan Reinauerb18f5222015-02-11 01:53:42 +01001#!/bin/sh
Stefan Reinauerb18f5222015-02-11 01:53:42 +01002#
Patrick Georgi7333a112020-05-08 20:48:04 +02003# SPDX-License-Identifier: GPL-2.0-only
4
Martin Roth1ce2ba62016-08-29 15:40:57 -06005# DESCR: Checkpatch on .c, .h, & Kconfig files in the tree
Stefan Reinauerb18f5222015-02-11 01:53:42 +01006
7LC_ALL=C export LC_ALL
Martin Roth1ce2ba62016-08-29 15:40:57 -06008
9# GNU BRE syntax list of files to examine
10INCLUDED_FILES='.*\.[ch]\|Kconfig.*$'
11
12EXCLUDED_DIRS="^payloads/libpayload/util/kconfig\|\
13^payloads/libpayload/curses/PDCurses\|\
Patrick Georgi54867862018-05-30 15:54:08 +020014^util/crossgcc/patches\|\
Nico Huber55e3a6a2019-02-12 12:53:07 +010015^util/inteltool\|\
Martin Roth1ce2ba62016-08-29 15:40:57 -060016^util/kconfig\|\
Nico Huberbfae9a82018-08-19 11:54:57 +020017^util/superiotool\|\
Martin Roth2a063be2017-04-05 21:29:06 -060018^src/vendorcode\|\
19^Documentation"
Martin Roth1ce2ba62016-08-29 15:40:57 -060020
Patrick Georgi7945f752019-02-27 19:57:23 +010021opts="--max-line-length 96"
22
Patrick Georgi54867862018-05-30 15:54:08 +020023# default: test src and util
Martin Roth1ce2ba62016-08-29 15:40:57 -060024if [ "$1" = "" ]; then
25 INCLUDED_DIRS="src util"
Patrick Georgi54867862018-05-30 15:54:08 +020026# special mode: take diff from stdin, but exclude the dirs
27elif [ "$1" = "diff" ]; then
28 args=$( echo $EXCLUDED_DIRS | \
29 sed -e 's,\\|, ,g' -e 's,\^,--exclude=,g' )
Patrick Georgi7945f752019-02-27 19:57:23 +010030 util/lint/checkpatch.pl --quiet --no-signoff $opts $args -
Patrick Georgi54867862018-05-30 15:54:08 +020031 exit $?
32# Space separated list of directories to test
Martin Roth1ce2ba62016-08-29 15:40:57 -060033else
34 INCLUDED_DIRS="$1"
35fi
36
37# We want word splitting here, so disable the shellcheck warnings
38# shellcheck disable=SC2046,SC2086
39FILELIST=$( git ls-files $INCLUDED_DIRS | \
40 grep $INCLUDED_FILES | \
41 grep -v $EXCLUDED_DIRS )
42
43for FILE in $FILELIST; do
Patrick Georgi7945f752019-02-27 19:57:23 +010044 util/lint/checkpatch.pl --show-types --file --quiet $opts "$FILE"
Martin Roth1ce2ba62016-08-29 15:40:57 -060045done