forked from OSchip/llvm-project
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:
parent
75f436c4ea
commit
c38af88764
|
@ -158,3 +158,8 @@ add_subdirectory(tools)
|
||||||
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/include/polly/Config/config.h.cmake
|
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/include/polly/Config/config.h.cmake
|
||||||
${POLLY_BINARY_DIR}/include/polly/Config/config.h )
|
${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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue