X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=build-root%2Fscripts%2Fcheckstyle.sh;h=f2f118ca20d8cb477e4d61a7e95ea8bfad8e337b;hb=3d2df215bf1de516ffbd8ee3815091ca3c3a492f;hp=bd2ba81371b1bedb2e419269d29b8325164bb1fc;hpb=dc15be2ca7c51772b00e4c5548934a35aa7e4add;p=vpp.git diff --git a/build-root/scripts/checkstyle.sh b/build-root/scripts/checkstyle.sh index bd2ba81371b..f2f118ca20d 100755 --- a/build-root/scripts/checkstyle.sh +++ b/build-root/scripts/checkstyle.sh @@ -1,5 +1,18 @@ #!/bin/bash +# Copyright (c) 2015 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + VPP_DIR=`dirname $0`/../../ EXIT_CODE=0 FIX="0" @@ -39,13 +52,20 @@ indent --version # Check to make sure we have clang-format. Exit if we don't with an error message, but # don't *fail*. +HAVE_CLANG_FORMAT=0 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 + x=$(echo "" | clang-format 2>&1) + if [[ "$x" == "" ]]; then + HAVE_CLANG_FORMAT=1 + else + echo "Output produced while formatting empty file (expected empty string):" + echo "$x" + echo "Could not find working \"clang-format\". Checking C++ files will cause abort" + fi fi cd ${VPP_DIR}