Stefan Reinauer | b18f522 | 2015-02-11 01:53:42 +0100 | [diff] [blame] | 1 | #!/bin/sh |
Stefan Reinauer | b18f522 | 2015-02-11 01:53:42 +0100 | [diff] [blame] | 2 | # |
Patrick Georgi | 7333a11 | 2020-05-08 20:48:04 +0200 | [diff] [blame] | 3 | # SPDX-License-Identifier: GPL-2.0-only |
| 4 | |
Martin Roth | 1ce2ba6 | 2016-08-29 15:40:57 -0600 | [diff] [blame] | 5 | # DESCR: Checkpatch on .c, .h, & Kconfig files in the tree |
Stefan Reinauer | b18f522 | 2015-02-11 01:53:42 +0100 | [diff] [blame] | 6 | |
| 7 | LC_ALL=C export LC_ALL |
Martin Roth | 1ce2ba6 | 2016-08-29 15:40:57 -0600 | [diff] [blame] | 8 | |
| 9 | # GNU BRE syntax list of files to examine |
| 10 | INCLUDED_FILES='.*\.[ch]\|Kconfig.*$' |
| 11 | |
| 12 | EXCLUDED_DIRS="^payloads/libpayload/util/kconfig\|\ |
| 13 | ^payloads/libpayload/curses/PDCurses\|\ |
Patrick Georgi | 5486786 | 2018-05-30 15:54:08 +0200 | [diff] [blame] | 14 | ^util/crossgcc/patches\|\ |
Nico Huber | 55e3a6a | 2019-02-12 12:53:07 +0100 | [diff] [blame] | 15 | ^util/inteltool\|\ |
Martin Roth | 1ce2ba6 | 2016-08-29 15:40:57 -0600 | [diff] [blame] | 16 | ^util/kconfig\|\ |
Nico Huber | bfae9a8 | 2018-08-19 11:54:57 +0200 | [diff] [blame] | 17 | ^util/superiotool\|\ |
Martin Roth | 2a063be | 2017-04-05 21:29:06 -0600 | [diff] [blame] | 18 | ^src/vendorcode\|\ |
| 19 | ^Documentation" |
Martin Roth | 1ce2ba6 | 2016-08-29 15:40:57 -0600 | [diff] [blame] | 20 | |
Patrick Georgi | 7945f75 | 2019-02-27 19:57:23 +0100 | [diff] [blame] | 21 | opts="--max-line-length 96" |
| 22 | |
Patrick Georgi | 5486786 | 2018-05-30 15:54:08 +0200 | [diff] [blame] | 23 | # default: test src and util |
Martin Roth | 1ce2ba6 | 2016-08-29 15:40:57 -0600 | [diff] [blame] | 24 | if [ "$1" = "" ]; then |
| 25 | INCLUDED_DIRS="src util" |
Patrick Georgi | 5486786 | 2018-05-30 15:54:08 +0200 | [diff] [blame] | 26 | # special mode: take diff from stdin, but exclude the dirs |
| 27 | elif [ "$1" = "diff" ]; then |
| 28 | args=$( echo $EXCLUDED_DIRS | \ |
| 29 | sed -e 's,\\|, ,g' -e 's,\^,--exclude=,g' ) |
Patrick Georgi | 7945f75 | 2019-02-27 19:57:23 +0100 | [diff] [blame] | 30 | util/lint/checkpatch.pl --quiet --no-signoff $opts $args - |
Patrick Georgi | 5486786 | 2018-05-30 15:54:08 +0200 | [diff] [blame] | 31 | exit $? |
| 32 | # Space separated list of directories to test |
Martin Roth | 1ce2ba6 | 2016-08-29 15:40:57 -0600 | [diff] [blame] | 33 | else |
| 34 | INCLUDED_DIRS="$1" |
| 35 | fi |
| 36 | |
| 37 | # We want word splitting here, so disable the shellcheck warnings |
| 38 | # shellcheck disable=SC2046,SC2086 |
| 39 | FILELIST=$( git ls-files $INCLUDED_DIRS | \ |
| 40 | grep $INCLUDED_FILES | \ |
| 41 | grep -v $EXCLUDED_DIRS ) |
| 42 | |
| 43 | for FILE in $FILELIST; do |
Patrick Georgi | 7945f75 | 2019-02-27 19:57:23 +0100 | [diff] [blame] | 44 | util/lint/checkpatch.pl --show-types --file --quiet $opts "$FILE" |
Martin Roth | 1ce2ba6 | 2016-08-29 15:40:57 -0600 | [diff] [blame] | 45 | done |