use clangformat cmake target

This commit is contained in:
Theo Butler
2019-05-18 12:54:35 +02:00
parent f9b9523d0c
commit 070e0700a8
3 changed files with 34 additions and 81 deletions

View File

@@ -170,10 +170,9 @@ if(NOT DEFINED SNMALLOC_ONLY_HEADER_LIBRARY)
message(STATUS "Generating clangformat target using ${CLANG_FORMAT}") message(STATUS "Generating clangformat target using ${CLANG_FORMAT}")
file(GLOB_RECURSE ALL_SOURCE_FILES *.cc *.h *.hh) file(GLOB_RECURSE ALL_SOURCE_FILES *.cc *.h *.hh)
add_custom_target( add_custom_target(
clangformat clangformat
COMMAND ${CLANG_FORMAT} COMMAND ${CLANG_FORMAT}
-i -i
${ALL_SOURCE_FILES} ${ALL_SOURCE_FILES})
)
endif() endif()
endif() endif()

View File

@@ -7,25 +7,25 @@ phases:
name: 'Hosted Ubuntu 1604' name: 'Hosted Ubuntu 1604'
parallel: 5 parallel: 5
matrix: matrix:
Clang_6 Debug: Clang-6 Debug:
CC: clang-6.0 CC: clang-6.0
CXX: clang++-6.0 CXX: clang++-6.0
BuildType: Debug BuildType: Debug
SelfHost: false SelfHost: false
Clang_6 Release: Clang-6 Release:
CC: clang-6.0 CC: clang-6.0
CXX: clang++-6.0 CXX: clang++-6.0
BuildType: Release BuildType: Release
SelfHost: false SelfHost: false
GCC_7 Debug: GCC-7 Debug:
CC: gcc-7 CC: gcc-7
CXX: g++-7 CXX: g++-7
BuildType: Debug BuildType: Debug
SelfHost: false SelfHost: false
GCC_7 Release: GCC-7 Release:
CC: gcc-7 CC: gcc-7
CXX: g++-7 CXX: g++-7
BuildType: Release BuildType: Release
@@ -82,71 +82,36 @@ phases:
failOnStderr: true failOnStderr: true
displayName: 'Test' displayName: 'Test'
- phase: Windows64bit - phase: Windows
queue: queue:
name: 'Hosted VS2017' name: 'Hosted VS2017'
parallel: 2 parallel: 5
matrix: matrix:
Debug: 64-bit Debug:
BuildType: Debug BuildType: Debug
Release: CMakeArgs: '-G"Visual Studio 15 2017 Win64"'
64-bit Release:
BuildType: Release BuildType: Release
CMakeArgs: '-G"Visual Studio 15 2017 Win64"'
steps: 64-bit Release Windows8Compat:
- 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:
BuildType: Release BuildType: Release
CMakeArgs: '-G"Visual Studio 15 2017 Win64" -DWIN8COMPAT=TRUE'
steps: 32-bit Debug:
- 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:
BuildType: Debug BuildType: Debug
Release: CMakeArgs: '-G"Visual Studio 15 2017"'
32-bit Release:
BuildType: Release BuildType: Release
CMakeArgs: '-G"Visual Studio 15 2017"'
steps: steps:
- task: CMake@1 - task: CMake@1
displayName: 'CMake .. -G"Visual Studio 15 2017"' displayName: 'CMake .. $(CMakeArgs)'
inputs: inputs:
cmakeArgs: '.. -G"Visual Studio 15 2017"' cmakeArgs: '.. $(CMakeArgs)'
- task: MSBuild@1 - task: MSBuild@1
displayName: 'Build solution build/snmalloc.sln' displayName: 'Build solution build/snmalloc.sln'
@@ -201,9 +166,16 @@ phases:
displayName: 'Install clang' displayName: 'Install clang'
- script: | - task: CMake@1
bash check-format.sh displayName: 'CMake ..'
inputs:
cmakeArgs: '..'
- script: |
if [ "$(git diff $(Build.SourceVersion))" != "" ]; then exit 1; fi
make clangformat
workingDirectory: build
displayName: 'Clang-Format' displayName: 'Clang-Format'
- script: | - script: |

View File

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