Martin Roth | 1c9c4b8 | 2016-11-30 10:29:39 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # This file is part of the coreboot project. |
| 3 | # |
| 4 | # Copyright (C) 2016 Google Inc. |
| 5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify |
| 7 | # it under the terms of the GNU General Public License as published by |
| 8 | # the Free Software Foundation; version 2 of the License. |
| 9 | # |
| 10 | # This program is distributed in the hope that it will be useful, |
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | # GNU General Public License for more details. |
| 14 | # |
| 15 | # DESCR: Check for auto-included headers |
| 16 | |
| 17 | LC_ALL=C export LC_ALL |
| 18 | |
| 19 | INCLUDED_DIRS='^src/' |
| 20 | EXCLUDED_FILES='src/include/kconfig.h' |
| 21 | |
| 22 | # TODO: Add rules when those patches are complete |
| 23 | HEADER_FILES="k*config" |
| 24 | |
| 25 | # 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] | 26 | if [ -n "$(command -v git)" ] && \ |
| 27 | [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ] |
| 28 | then |
Martin Roth | 1c9c4b8 | 2016-11-30 10:29:39 -0700 | [diff] [blame] | 29 | GREP_FILES="git grep -n" |
| 30 | else |
| 31 | GREP_FILES="grep -rn" |
| 32 | fi |
| 33 | |
| 34 | for header in $HEADER_FILES; do |
| 35 | ${GREP_FILES} "#\s*include\s\+[\"<]\s*${header}\.h\s*[\">]" | \ |
| 36 | grep "$INCLUDED_DIRS" | \ |
| 37 | grep -v "$EXCLUDED_FILES"; \ |
Alex Thiessen | 687b961 | 2018-01-18 23:11:07 +0000 | [diff] [blame] | 38 | done |