af06e9adea
For some reason, the '\s' syntax is causing an error for me under freebsd. It's entirely possible that I'm doing something wrong, but this change should be fine regardless. Freebsd's grep, GNU grep, and git grep all handle posix regex classes, so this change should be transparent. Signed-off-by: Martin Roth <gaumless@gmail.com> Change-Id: I489ec13b4ea2e9c17692888e42b8741763b1a2c5 Reviewed-on: https://review.coreboot.org/c/coreboot/+/63532 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Felix Singer <felixsinger@posteo.net>
28 lines
691 B
Bash
Executable file
28 lines
691 B
Bash
Executable file
#!/usr/bin/env sh
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
# DESCR: Check for auto-included headers
|
|
|
|
LC_ALL=C export LC_ALL
|
|
|
|
INCLUDED_DIRS='^src/'
|
|
EXCLUDED_FILES='src/include/kconfig.h'
|
|
|
|
# TODO: Add rules when those patches are complete
|
|
HEADER_FILES="k*config"
|
|
|
|
# Use git grep if the code is in a git repo, otherwise use grep.
|
|
if [ -n "$(command -v git)" ] && \
|
|
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
|
then
|
|
GREP_FILES="git grep -n"
|
|
else
|
|
GREP_FILES="grep -rn"
|
|
fi
|
|
|
|
for header in $HEADER_FILES; do
|
|
${GREP_FILES} "#[[:blank:]]*include[[:blank:]]\+[\"<][[:blank:]]*${header}\.h[[:blank:]]*[\">]" | \
|
|
grep "$INCLUDED_DIRS" | \
|
|
grep -v "$EXCLUDED_FILES"; \
|
|
done
|