aboutsummaryrefslogtreecommitdiffstats
path: root/build-root/scripts
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2017-06-12 06:49:33 +0200
committerNeale Ranns <nranns@cisco.com>2017-09-19 20:06:08 +0000
commitdc15be2ca7c51772b00e4c5548934a35aa7e4add (patch)
treeba4b707b73d21d3875264248a3affa93249816d3 /build-root/scripts
parent9d063047eb1a3738cb0fc9ebebb55793d155bb20 (diff)
Add C++ API
Change-Id: Iff634f22d43470e2dc028387b3816257fd7b4156 Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'build-root/scripts')
-rwxr-xr-xbuild-root/scripts/checkstyle.sh62
1 files changed, 50 insertions, 12 deletions
diff --git a/build-root/scripts/checkstyle.sh b/build-root/scripts/checkstyle.sh
index 55fe4ab53ae..bd2ba81371b 100755
--- a/build-root/scripts/checkstyle.sh
+++ b/build-root/scripts/checkstyle.sh
@@ -32,37 +32,75 @@ fi
# don't *fail*.
command -v indent > /dev/null
if [ $? != 0 ]; then
- echo "Cound not find required commend \"indent\". Checkstyle aborted"
+ echo "Cound not find required command \"indent\". Checkstyle aborted"
exit ${EXIT_CODE}
fi
indent --version
+# Check to make sure we have clang-format. Exit if we don't with an error message, but
+# don't *fail*.
+command -v clang-format > /dev/null
+if [ $? != 0 ]; then
+ echo "Could not find command \"clang-format\". Checking C++ files will cause abort"
+ HAVE_CLANG_FORMAT=0
+else
+ HAVE_CLANG_FORMAT=1
+ clang-format --version
+fi
+
cd ${VPP_DIR}
git status
for i in ${FILELIST}; do
if [ -f ${i} ] && [ ${i} != "build-root/scripts/checkstyle.sh" ] && [ ${i} != "extras/emacs/fix-coding-style.el" ]; then
grep -q "fd.io coding-style-patch-verification: ON" ${i}
if [ $? == 0 ]; then
+ EXTENSION=`basename ${i} | sed 's/^\w\+.//'`
+ case ${EXTENSION} in
+ hpp|cpp|cc|hh)
+ CMD="clang-format"
+ if [ ${HAVE_CLANG_FORMAT} == 0 ]; then
+ echo "C++ file detected. Abort. (missing clang-format)"
+ exit ${EXIT_CODE}
+ fi
+ ;;
+ *)
+ CMD="indent"
+ ;;
+ esac
CHECKSTYLED_FILES="${CHECKSTYLED_FILES} ${i}"
if [ ${FIX} == 0 ]; then
- indent ${i} -o ${i}.out1 > /dev/null 2>&1
- indent ${i}.out1 -o ${i}.out2 > /dev/null 2>&1
- # Remove trailing whitespace
- sed -i -e 's/[[:space:]]*$//' ${i}.out2
+ if [ "${CMD}" == "clang-format" ]
+ then
+ clang-format ${i} > ${i}.out2
+ else
+ indent ${i} -o ${i}.out1 > /dev/null 2>&1
+ indent ${i}.out1 -o ${i}.out2 > /dev/null 2>&1
+ fi
+ # Remove trailing whitespace
+ sed -i -e 's/[[:space:]]*$//' ${i}.out2
diff -q ${i} ${i}.out2
else
- indent ${i}
- indent ${i}
- # Remove trailing whitespace
- sed -i -e 's/[[:space:]]*$//' ${i}
+ if [ "${CMD}" == "clang-format" ]; then
+ clang-format -i ${i} > /dev/null 2>&1
+ else
+ indent ${i}
+ indent ${i}
+ fi
+ # Remove trailing whitespace
+ sed -i -e 's/[[:space:]]*$//' ${i}
fi
if [ $? != 0 ]; then
EXIT_CODE=1
echo
echo "Checkstyle failed for ${i}."
- echo "Run indent (twice!) as shown to fix the problem:"
- echo "indent ${VPP_DIR}${i}"
- echo "indent ${VPP_DIR}${i}"
+ if [ "${CMD}" == "clang-format" ]; then
+ echo "Run clang-format as shown to fix the problem:"
+ echo "clang-format -i ${VPP_DIR}${i}"
+ else
+ echo "Run indent (twice!) as shown to fix the problem:"
+ echo "indent ${VPP_DIR}${i}"
+ echo "indent ${VPP_DIR}${i}"
+ fi
fi
if [ -f ${i}.out1 ]; then
rm ${i}.out1