blob: 11cb6b750c91d6728ce6ef517f6d630b359ac6b6 [file] [log] [blame]
Martin Roth1c9c4b82016-11-30 10:29:39 -07001#!/bin/sh
Martin Roth1c9c4b82016-11-30 10:29:39 -07002#
Patrick Georgi7333a112020-05-08 20:48:04 +02003# SPDX-License-Identifier: GPL-2.0-only
4
Martin Roth1c9c4b82016-11-30 10:29:39 -07005# DESCR: Check for auto-included headers
6
7LC_ALL=C export LC_ALL
8
9INCLUDED_DIRS='^src/'
10EXCLUDED_FILES='src/include/kconfig.h'
11
12# TODO: Add rules when those patches are complete
13HEADER_FILES="k*config"
14
15# Use git grep if the code is in a git repo, otherwise use grep.
Alex Thiessen73f19dc2018-01-16 23:05:48 +000016if [ -n "$(command -v git)" ] && \
17 [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
18then
Martin Roth1c9c4b82016-11-30 10:29:39 -070019 GREP_FILES="git grep -n"
20else
21 GREP_FILES="grep -rn"
22fi
23
24for 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 Thiessen687b9612018-01-18 23:11:07 +000028done