Martin Roth | 1c9c4b8 | 2016-11-30 10:29:39 -0700 | [diff] [blame] | 1 | #!/bin/sh |
Martin Roth | 1c9c4b8 | 2016-11-30 10:29:39 -0700 | [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 | 1c9c4b8 | 2016-11-30 10:29:39 -0700 | [diff] [blame] | 5 | # DESCR: Check for auto-included headers |
| 6 | |
| 7 | LC_ALL=C export LC_ALL |
| 8 | |
| 9 | INCLUDED_DIRS='^src/' |
| 10 | EXCLUDED_FILES='src/include/kconfig.h' |
| 11 | |
| 12 | # TODO: Add rules when those patches are complete |
| 13 | HEADER_FILES="k*config" |
| 14 | |
| 15 | # Use git grep if the code is in a git repo, otherwise use grep. |
Alex Thiessen | 73f19dc | 2018-01-16 23:05:48 +0000 | [diff] [blame] | 16 | if [ -n "$(command -v git)" ] && \ |
| 17 | [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ] |
| 18 | then |
Martin Roth | 1c9c4b8 | 2016-11-30 10:29:39 -0700 | [diff] [blame] | 19 | GREP_FILES="git grep -n" |
| 20 | else |
| 21 | GREP_FILES="grep -rn" |
| 22 | fi |
| 23 | |
| 24 | for header in $HEADER_FILES; do |
| 25 | ${GREP_FILES} "#\s*include\s\+[\"<]\s*${header}\.h\s*[\">]" | \ |
| 26 | grep "$INCLUDED_DIRS" | \ |
| 27 | grep -v "$EXCLUDED_FILES"; \ |
Alex Thiessen | 687b961 | 2018-01-18 23:11:07 +0000 | [diff] [blame] | 28 | done |