| 1 | #!/usr/bin/env sh |
| 2 | # |
| 3 | # SPDX-License-Identifier: GPL-2.0-only |
| 4 | |
| 5 | # DESCR: Checkpatch on .c, .h, & Kconfig files in the tree |
| 6 | |
| 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" |
| 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\|\ |
| 20 | ^src/vendorcode/wuffs\|\ |
| 21 | ^util/coreboot-configurator\|\ |
| 22 | ^util/crossgcc/patches\|\ |
| 23 | ^util/inteltool\|\ |
| 24 | ^util/kconfig\|\ |
| 25 | ^util/superiotool\|\ |
| 26 | ^Documentation" |
| 27 | |
| 28 | opts="--max-line-length 96" |
| 29 | |
| 30 | # default: test src and util |
| 31 | if [ "$1" = "" ]; then |
| 32 | INCLUDED_DIRS="src util tests" |
| 33 | # special mode: take diff from stdin, but exclude the dirs |
| 34 | elif [ "$1" = "diff" ]; then |
| 35 | args=$( echo $EXCLUDED_DIRS | \ |
| 36 | sed -e 's,\\|, ,g' -e 's,\^,--exclude=,g' ) |
| 37 | util/lint/checkpatch.pl --quiet --no-signoff $opts $args - |
| 38 | exit $? |
| 39 | # Space separated list of directories to test |
| 40 | else |
| 41 | INCLUDED_DIRS="$1" |
| 42 | fi |
| 43 | |
| 44 | # We want word splitting here, so disable the shellcheck warnings |
| 45 | # shellcheck disable=SC2046,SC2086 |
| 46 | FILELIST=$( ${FIND_FILES} $INCLUDED_DIRS | \ |
| 47 | grep $INCLUDED_FILES | \ |
| 48 | grep -v $EXCLUDED_DIRS ) |
| 49 | |
| 50 | for FILE in $FILELIST; do |
| 51 | util/lint/checkpatch.pl --show-types --file --quiet $opts "$FILE" |
| 52 | done |