cmake: add command polly-check-format

This command runs clang-format on all files and reports formatting problems

llvm-svn: 175170
This commit is contained in:
Tobias Grosser 2013-02-14 16:19:16 +00:00
parent 75f436c4ea
commit c38af88764
2 changed files with 24 additions and 0 deletions

View File

@ -158,3 +158,8 @@ add_subdirectory(tools)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/include/polly/Config/config.h.cmake
${POLLY_BINARY_DIR}/include/polly/Config/config.h )
# Add target to check formatting of polly files
file( GLOB_RECURSE files *.h *.cpp)
add_custom_command( OUTPUT formatting COMMAND
${CMAKE_CURRENT_SOURCE_DIR}/utils/check_format.sh ${files})
add_custom_target(polly-check-format ALL DEPENDS formatting)

19
polly/utils/check_format.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
OK=0
for ARG in "$@"
do
clang-format $1 | diff $1 -
if [[ $? -eq 1 ]]; then
OK=1
fi
done
if [[ $OK -eq "1" ]]; then
echo "Error: clang-format reported formatting differences"
else
echo "OK: clang-format reported no formatting differences"
fi