cmake: Provide path to installed clang-format

This will now also enable the automatic formatting checks in the Polly buildbot.

llvm-svn: 195507
This commit is contained in:
Tobias Grosser 2013-11-22 22:42:13 +00:00
parent cb14bbcc48
commit c8f0779c38
3 changed files with 20 additions and 9 deletions

View File

@ -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)

View File

@ -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

View File

@ -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