Martin Roth | 0ad5fbd | 2020-12-24 12:06:38 -0700 | [diff] [blame] | 1 | #!/usr/bin/env 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 | |
Martin Roth | d81debd | 2022-06-03 00:06:57 -0600 | [diff] [blame] | 7 | LINTDIR="$( |
| 8 | cd -- "$(dirname "$0")" > /dev/null 2>&1 || return |
| 9 | pwd -P |
| 10 | )" |
| 11 | |
| 12 | # shellcheck source=helper_functions.sh |
| 13 | . "${LINTDIR}/helper_functions.sh" |
Martin Roth | 1ce2ba6 | 2016-08-29 15:40:57 -0600 | [diff] [blame] | 14 | |
| 15 | # GNU BRE syntax list of files to examine |
| 16 | INCLUDED_FILES='.*\.[ch]\|Kconfig.*$' |
| 17 | |
| 18 | EXCLUDED_DIRS="^payloads/libpayload/util/kconfig\|\ |
| 19 | ^payloads/libpayload/curses/PDCurses\|\ |
Sean Rhodes | c9bc7a7 | 2021-11-10 11:22:19 +0000 | [diff] [blame] | 20 | ^util/coreboot-configurator\|\ |
Patrick Georgi | 5486786 | 2018-05-30 15:54:08 +0200 | [diff] [blame] | 21 | ^util/crossgcc/patches\|\ |
Nico Huber | 55e3a6a | 2019-02-12 12:53:07 +0100 | [diff] [blame] | 22 | ^util/inteltool\|\ |
Martin Roth | 1ce2ba6 | 2016-08-29 15:40:57 -0600 | [diff] [blame] | 23 | ^util/kconfig\|\ |
Nico Huber | bfae9a8 | 2018-08-19 11:54:57 +0200 | [diff] [blame] | 24 | ^util/superiotool\|\ |
Martin Roth | 2a063be | 2017-04-05 21:29:06 -0600 | [diff] [blame] | 25 | ^Documentation" |
Martin Roth | 1ce2ba6 | 2016-08-29 15:40:57 -0600 | [diff] [blame] | 26 | |
Patrick Georgi | 7945f75 | 2019-02-27 19:57:23 +0100 | [diff] [blame] | 27 | opts="--max-line-length 96" |
| 28 | |
Patrick Georgi | 5486786 | 2018-05-30 15:54:08 +0200 | [diff] [blame] | 29 | # default: test src and util |
Martin Roth | 1ce2ba6 | 2016-08-29 15:40:57 -0600 | [diff] [blame] | 30 | if [ "$1" = "" ]; then |
Jan Dabros | ffa58cf | 2020-07-16 13:38:01 +0200 | [diff] [blame] | 31 | INCLUDED_DIRS="src util tests" |
Patrick Georgi | 5486786 | 2018-05-30 15:54:08 +0200 | [diff] [blame] | 32 | # special mode: take diff from stdin, but exclude the dirs |
| 33 | elif [ "$1" = "diff" ]; then |
| 34 | args=$( echo $EXCLUDED_DIRS | \ |
| 35 | sed -e 's,\\|, ,g' -e 's,\^,--exclude=,g' ) |
Patrick Georgi | 7945f75 | 2019-02-27 19:57:23 +0100 | [diff] [blame] | 36 | util/lint/checkpatch.pl --quiet --no-signoff $opts $args - |
Patrick Georgi | 5486786 | 2018-05-30 15:54:08 +0200 | [diff] [blame] | 37 | exit $? |
| 38 | # Space separated list of directories to test |
Martin Roth | 1ce2ba6 | 2016-08-29 15:40:57 -0600 | [diff] [blame] | 39 | else |
| 40 | INCLUDED_DIRS="$1" |
| 41 | fi |
| 42 | |
| 43 | # We want word splitting here, so disable the shellcheck warnings |
| 44 | # shellcheck disable=SC2046,SC2086 |
Martin Roth | d81debd | 2022-06-03 00:06:57 -0600 | [diff] [blame] | 45 | FILELIST=$( ${FIND_FILES} $INCLUDED_DIRS | \ |
Martin Roth | 1ce2ba6 | 2016-08-29 15:40:57 -0600 | [diff] [blame] | 46 | grep $INCLUDED_FILES | \ |
| 47 | grep -v $EXCLUDED_DIRS ) |
| 48 | |
| 49 | for FILE in $FILELIST; do |
Patrick Georgi | 7945f75 | 2019-02-27 19:57:23 +0100 | [diff] [blame] | 50 | util/lint/checkpatch.pl --show-types --file --quiet $opts "$FILE" |
Martin Roth | 1ce2ba6 | 2016-08-29 15:40:57 -0600 | [diff] [blame] | 51 | done |