diff options
-rw-r--r-- | polly/CMakeLists.txt | 2 | ||||
-rwxr-xr-x | polly/utils/check_format.sh | 14 | ||||
-rwxr-xr-x | polly/utils/update_format.sh | 13 |
3 files changed, 20 insertions, 9 deletions
diff --git a/polly/CMakeLists.txt b/polly/CMakeLists.txt index 1b63b6b440a..6f86772f681 100644 --- a/polly/CMakeLists.txt +++ b/polly/CMakeLists.txt @@ -168,8 +168,10 @@ file( GLOB_RECURSE files *.h *.cpp) file( GLOB_RECURSE jsonfiles lib/JSON/*.h lib/JSON/*.cpp) list( REMOVE_ITEM files ${jsonfiles} ) add_custom_command( OUTPUT formatting COMMAND + CLANG_FORMAT=${LLVM_BINARY_DIR}/bin/clang-format ${CMAKE_CURRENT_SOURCE_DIR}/utils/check_format.sh ${files}) add_custom_target(polly-check-format DEPENDS formatting) add_custom_command( OUTPUT formatting-update COMMAND + CLANG_FORMAT=${LLVM_BINARY_DIR}/bin/clang-format ${CMAKE_CURRENT_SOURCE_DIR}/utils/update_format.sh ${files}) add_custom_target(polly-update-format DEPENDS formatting-update) diff --git a/polly/utils/check_format.sh b/polly/utils/check_format.sh index d87e00dc2e0..120a6a24af6 100755 --- a/polly/utils/check_format.sh +++ b/polly/utils/check_format.sh @@ -1,16 +1,20 @@ #!/bin/bash -if ! which clang-format; then - echo "Error: cannot find clang-format in your path" - # Do not fail. This is a temporary fix to silence buildbots. - exit 0 +CLANG_FORMAT=${CLANG_FORMAT} + +if [ "${CLANG_FORMAT}x" = "x" ]; then + CLANG_FORMAT=`which clang-format` + if [ "${CLANG_FORMAT}x" = "x" ]; then + echo "Error: cannot find clang-format in your path" + exit 1 + fi fi OK=0 for ARG in "$@" do - clang-format $ARG | diff -u $ARG - + ${CLANG_FORMAT} $ARG | diff -u $ARG - if [[ $? -eq 1 ]]; then OK=1 diff --git a/polly/utils/update_format.sh b/polly/utils/update_format.sh index 8fee5cc330b..9226fc6af52 100755 --- a/polly/utils/update_format.sh +++ b/polly/utils/update_format.sh @@ -1,11 +1,16 @@ #!/bin/bash -if ! which clang-format; then - echo "Error: cannot find clang-format in your path" - exit 1 +CLANG_FORMAT=${CLANG_FORMAT} + +if [ "${CLANG_FORMAT}x" = "x" ]; then + CLANG_FORMAT=`which clang-format` + if [ "${CLANG_FORMAT}x" = "x" ]; then + echo "Error: cannot find clang-format in your path" + exit 1 + fi fi for ARG in "$@" do - clang-format -i $ARG + ${CLANG_FORMAT} -i $ARG done |