From 070e0700a802e51495f7c365e3d8e9da5075e137 Mon Sep 17 00:00:00 2001 From: Theo Butler Date: Sat, 18 May 2019 12:54:35 +0200 Subject: [PATCH] use clangformat cmake target --- CMakeLists.txt | 11 +++--- azure-pipelines.yml | 86 +++++++++++++++------------------------------ check-format.sh | 18 ---------- 3 files changed, 34 insertions(+), 81 deletions(-) delete mode 100644 check-format.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index ecafc9d..3649761 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,10 +170,9 @@ if(NOT DEFINED SNMALLOC_ONLY_HEADER_LIBRARY) message(STATUS "Generating clangformat target using ${CLANG_FORMAT}") file(GLOB_RECURSE ALL_SOURCE_FILES *.cc *.h *.hh) add_custom_target( - clangformat - COMMAND ${CLANG_FORMAT} - -i - ${ALL_SOURCE_FILES} - ) + clangformat + COMMAND ${CLANG_FORMAT} + -i + ${ALL_SOURCE_FILES}) endif() -endif() \ No newline at end of file +endif() diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d803ad3..cd302c8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,25 +7,25 @@ phases: name: 'Hosted Ubuntu 1604' parallel: 5 matrix: - Clang_6 Debug: + Clang-6 Debug: CC: clang-6.0 CXX: clang++-6.0 BuildType: Debug SelfHost: false - Clang_6 Release: + Clang-6 Release: CC: clang-6.0 CXX: clang++-6.0 BuildType: Release SelfHost: false - GCC_7 Debug: + GCC-7 Debug: CC: gcc-7 CXX: g++-7 BuildType: Debug SelfHost: false - GCC_7 Release: + GCC-7 Release: CC: gcc-7 CXX: g++-7 BuildType: Release @@ -82,71 +82,36 @@ phases: failOnStderr: true displayName: 'Test' -- phase: Windows64bit +- phase: Windows queue: name: 'Hosted VS2017' - parallel: 2 + parallel: 5 matrix: - Debug: + 64-bit Debug: BuildType: Debug - Release: + CMakeArgs: '-G"Visual Studio 15 2017 Win64"' + + 64-bit Release: BuildType: Release + CMakeArgs: '-G"Visual Studio 15 2017 Win64"' - steps: - - task: CMake@1 - displayName: 'CMake .. -G"Visual Studio 15 2017 Win64"' - inputs: - cmakeArgs: '.. -G"Visual Studio 15 2017 Win64"' - - - task: MSBuild@1 - displayName: 'Build solution build/snmalloc.sln' - inputs: - solution: build/snmalloc.sln - msbuildArguments: '/m /p:Configuration=$(BuildType)' - - - script: 'ctest -j 4 --interactive-debug-mode 0 --output-on-failure -C $(BuildType)' - workingDirectory: build - displayName: 'Run Ctest' - -- phase: Windows8Compat - queue: - name: 'Hosted VS2017' - parallel: 2 - matrix: - Release: + 64-bit Release Windows8Compat: BuildType: Release + CMakeArgs: '-G"Visual Studio 15 2017 Win64" -DWIN8COMPAT=TRUE' - steps: - - task: CMake@1 - displayName: 'CMake .. -G"Visual Studio 15 2017 Win64"' - inputs: - cmakeArgs: '.. -G"Visual Studio 15 2017 Win64" -DWIN8COMPAT=TRUE' - - - task: MSBuild@1 - displayName: 'Build solution build/snmalloc.sln' - inputs: - solution: build/snmalloc.sln - msbuildArguments: '/m /p:Configuration=$(BuildType)' - - - script: 'ctest -j 4 --interactive-debug-mode 0 --output-on-failure -C $(BuildType)' - workingDirectory: build - displayName: 'Run Ctest' - -- phase: Windows32bit - queue: - name: 'Hosted VS2017' - parallel: 2 - matrix: - Debug: + 32-bit Debug: BuildType: Debug - Release: + CMakeArgs: '-G"Visual Studio 15 2017"' + + 32-bit Release: BuildType: Release + CMakeArgs: '-G"Visual Studio 15 2017"' steps: - task: CMake@1 - displayName: 'CMake .. -G"Visual Studio 15 2017"' + displayName: 'CMake .. $(CMakeArgs)' inputs: - cmakeArgs: '.. -G"Visual Studio 15 2017"' + cmakeArgs: '.. $(CMakeArgs)' - task: MSBuild@1 displayName: 'Build solution build/snmalloc.sln' @@ -201,9 +166,16 @@ phases: displayName: 'Install clang' - - script: | - bash check-format.sh + - task: CMake@1 + displayName: 'CMake ..' + inputs: + cmakeArgs: '..' + - script: | + if [ "$(git diff $(Build.SourceVersion))" != "" ]; then exit 1; fi + make clangformat + + workingDirectory: build displayName: 'Clang-Format' - script: | diff --git a/check-format.sh b/check-format.sh deleted file mode 100644 index bcd1deb..0000000 --- a/check-format.sh +++ /dev/null @@ -1,18 +0,0 @@ - -set -u - -unformatted_files="" -for f in `find . -name *.h -o -name *.hh -o -name *.cc`; do - d=`clang-format -style=file $f | diff $f -` - if [ "$d" != "" ]; then - if [ "$unformatted_files" != "" ]; then - unformatted_files+=$'\n' - fi - unformatted_files+="$f" - fi -done - -if [ "$unformatted_files" != "" ]; then - echo "$unformatted_files" - exit 1 -fi