summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--polly/CMakeLists.txt5
-rwxr-xr-xpolly/utils/check_format.sh19
2 files changed, 24 insertions, 0 deletions
diff --git a/polly/CMakeLists.txt b/polly/CMakeLists.txt
index a60c50e14093..71c2dc6c5e4f 100644
--- a/polly/CMakeLists.txt
+++ b/polly/CMakeLists.txt
@@ -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)
diff --git a/polly/utils/check_format.sh b/polly/utils/check_format.sh
new file mode 100755
index 000000000000..94a14a1873f2
--- /dev/null
+++ b/polly/utils/check_format.sh
@@ -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
+