1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-26 23:11:19 +01:00

Merge pull request #1789 from LudwigOrtmann/externc_check

CI: extern "C" check
This commit is contained in:
Ludwig Ortmann 2014-10-17 22:57:45 -07:00
commit d232595a1f
2 changed files with 41 additions and 0 deletions

View File

@ -51,6 +51,10 @@ script:
# Remove the --error-exitcode=0` when all warnings of cppcheck have been
# taken care of in master.
- ./dist/tools/cppcheck/check.sh master --error-exitcode=0
# TODO:
# Remove the `AC` argument when all headers have been
# taken care of in master.
- ./dist/tools/externc/check.sh master AC
notifications:
email: false

37
dist/tools/externc/check.sh vendored Executable file
View File

@ -0,0 +1,37 @@
#!/bin/sh
# customizable
CHECKROOT=$(dirname "${0}")
# prepare
ROOT=$(git rev-parse --show-toplevel)
EXIT_CODE=0
BRANCH="${1}"
DIFFFILTER="${2}"
# set default diff-filter
if [ -z "${DIFFFILTER}" ]; then
DIFFFILTER="ACMR"
fi
# select files to check
if [ -z "${BRANCH}" ]; then
FILES="$(git ls-tree -r --full-tree --name-only HEAD | grep -E '\.h$')"
else
FILES="$(git diff --diff-filter=${DIFFFILTER} --name-only ${BRANCH} | grep -E '\.h$')"
fi
# check files
for FILE in ${FILES}; do
if head -100 "${ROOT}/${FILE}" \
| sed -e 's/$/ /' \
| tr -d '\r\n' \
| sed -e 's/ */ /g' \
| grep -v -q '#ifdef __cplusplus extern "C" { #endif'; \
then
EXIT_CODE=1
echo "file does not have a C++ compatible header: '${FILE}'"
fi
done
exit ${EXIT_CODE}