-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,48 @@ | ||
#! /bin/bash | ||
|
||
if [ -f src/all.h ]; then | ||
for HEADER in src/*.h; do | ||
if [ $(basename ${HEADER}) == "all.h" ]; then | ||
continue | ||
fi | ||
if [ ! $(grep $(basename ${HEADER}) src/all.h) ]; then | ||
echo ${HEADER} is not included in all.h | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
HEADER_PATH="src/platform" | ||
|
||
function file_included() { | ||
local HEADER_TO_GREP=${1} | ||
local HEADER_TO_SERACH=${2} | ||
local OCCUR_CNT | ||
|
||
# grep -c $(basename ${HEADER_TO_SEARCH}) < ${HEADER_TO_GREP} | ||
# exit 1 | ||
OCCUR_CNT=$(grep -c $(basename ${HEADER_TO_SEARCH}) < ${HEADER_TO_GREP} || true) | ||
case "${OCCUR_CNT}" in | ||
1) | ||
true | ||
;; | ||
0) | ||
echo "${HEADER_TO_SEARCH} is not included in ${HEADER_TO_GREP}" | ||
;; | ||
*) | ||
echo "Parse error" | ||
exit 1 | ||
fi | ||
done | ||
exit 0 | ||
fi | ||
exit 1 | ||
;; | ||
esac | ||
} | ||
|
||
function main() { | ||
local ERR=0 | ||
local HEADER | ||
local HEADER_TO_GREP="${HEADER_PATH}/all.h" | ||
if [ -f ${HEADER_TO_GREP} ]; then | ||
for HEADER_TO_SEARCH in ${HEADER_PATH}/*.h; do | ||
if [ $(basename ${HEADER_TO_SEARCH}) == "all.h" ]; then | ||
continue | ||
fi | ||
# echo "Check ${HEADER_TO_SEARCH}" | ||
file_included ${HEADER_TO_GREP} ${HEADER_TO_SEARCH} | ||
done | ||
exit ${ERR} | ||
fi | ||
exit 1 | ||
} | ||
|
||
main |