Hide the clang-tidy behind a build option

This commit is contained in:
Sameer Rahmani 2021-10-17 22:22:49 +01:00
parent fd66e47cd7
commit cbb0b0428e
7 changed files with 39 additions and 5 deletions

View File

@ -15,4 +15,20 @@ AlignConsecutiveBitFields: Consecutive
AlignEscapedNewlines: Left
AlwaysBreakTemplateDeclarations: Yes
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^"(serene)/'
Priority: 1
SortPriority: 1
CaseSensitive: true
- Regex: '^<(llvm|llvm-c|clang|clang-c|mlir)/'
Priority: 3
SortPriority: 3
CaseSensitive: true
- Regex: '<[[:alnum:].]+>'
Priority: 5
- Regex: '.*'
Priority: 2
SortPriority: 0
SortIncludes: true
SortUsingDeclarations: true
...

View File

@ -33,6 +33,7 @@ option(SERENE_BUILD_TESTING "Enable tests" OFF)
option(SERENE_ENABLE_BUILDID "Enable build id." OFF)
option(SERENE_ENABLE_THINLTO "Enable ThisLTO." ON)
option(SERENE_ENABLE_DOCS "Enable document generation" OFF)
option(SERENE_ENABLE_TIDY "Enable clang tidy check" OFF)
option(SERENE_DISABLE_CCACHE "Disable automatic ccache integration" OFF)
# libserene
@ -60,8 +61,9 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
set(SRC_DIR ${CMAKE_SOURCE_DIR}/src)
set(CMAKE_CXX_CLANG_TIDY clang-tidy)
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE include-what-you-use)
if(SERENE_ENABLE_TIDY)
find_program(CLANG_TIDY_PATH NAMES clang-tidy REQUIRED)
endif()
# Let's ensure -std=c++xx instead of -std=g++xx
set(CMAKE_CXX_EXTENSIONS OFF)

10
builder
View File

@ -34,7 +34,7 @@ BUILD_DIR=$ROOT_DIR/build
ME=$(cd "$(dirname "$0")/." >/dev/null 2>&1 ; pwd -P)
CMAKEARGS_DEBUG=" -DCMAKE_BUILD_TYPE=Debug -DSERENE_WITH_MLIR_CL_OPTION=ON"
CMAKEARGS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DSERENE_CCACHE_DIR=${HOME}/.ccache"
CMAKEARGS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DSERENE_CCACHE_DIR=$HOME/.ccache"
# The scan-build utility scans the build for bugs checkout the man page
scanbuild="scan-build --force-analyze-debug-code --use-analyzer=$(which clang)"
@ -71,7 +71,7 @@ function compile() {
}
function build() {
build-gen
build-gen "$@"
pushed_build
cmake --build .
popd_build
@ -144,6 +144,12 @@ case "$command" in
mkdir -p "$BUILD_DIR"
build "${@:2}"
;;
"build-tidy")
clean
mkdir -p "$BUILD_DIR"
build "-DSERENE_ENABLE_TIDY=ON" "${@:2}"
;;
"build-20")
clean
mkdir -p "$BUILD_DIR"

View File

@ -1,5 +1,7 @@
#! /bin/bash
set -e
function get_changed_files() {
local add_modified
local renamed
@ -41,7 +43,6 @@ function git_add_changes() {
then
git add $files
fi
}

View File

@ -78,6 +78,9 @@ set_target_properties(serene PROPERTIES
# LTO support
INTERPROCEDURAL_OPTIMIZATION TRUE)
if(SERENE_ENABLE_TIDY)
set_target_properties(serene PROPERTIES CXX_CLANG_TIDY ${CLANG_TIDY_PATH})
endif()
# Do we need to build serene as a shared lib? default is "yes"
if(SERENE_SHARED_LIB)

View File

@ -26,6 +26,9 @@ set_target_properties(serene-repl PROPERTIES
# LTO support
INTERPROCEDURAL_OPTIMIZATION TRUE)
if(SERENE_ENABLE_TIDY)
set_target_properties(serene PROPERTIES CXX_CLANG_TIDY ${CLANG_TIDY_PATH})
endif()
if (CPP_20_SUPPORT)
target_compile_features(serene-repl PRIVATE cxx_std_20)

View File

@ -25,6 +25,9 @@ set_target_properties(serenec PROPERTIES
# LTO support
INTERPROCEDURAL_OPTIMIZATION TRUE)
if(SERENE_ENABLE_TIDY)
set_target_properties(serenec PROPERTIES CXX_CLANG_TIDY ${CLANG_TIDY_PATH})
endif()
if (CPP_20_SUPPORT)
target_compile_features(serenec PRIVATE cxx_std_20)