Skip to content

Commit

Permalink
Tweak running tidy on build and remove msvc analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
kingsamchen committed Oct 27, 2024
1 parent b056aaf commit 4333f7a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ jobs:
- name: Run clang-tidy
run: |
cmake --preset linux-release -DESL_USE_SANITIZER=OFF
cmake --preset linux-release -DESL_USE_SANITIZER=""
run-clang-tidy-19 tests -p out/linux-release
4 changes: 1 addition & 3 deletions .github/workflows/linux_build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,4 @@ jobs:
env:
CXX: ${{matrix.cxx}}
run: |
cmake --preset linux-release -DESL_ENABLE_CLANG_TIDY=OFF
cmake --build --preset linux-release
ctest --preset linux-release
cmake --workflow --preset linux-release
13 changes: 12 additions & 1 deletion .github/workflows/windows_build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,23 @@ jobs:
# https://github.com/actions/virtual-environments.
# Only x64 is supported.
os: [windows-2019, windows-2022]
run_tidy: [OFF, ON]
include:
- os: windows-2019
run_tidy: OFF
- os: windows-2022
run_tidy: ON
exclude:
- os: windows-2019
run_tidy: ON
- os: windows-2022
run_tidy: OFF

steps:
- uses: actions/checkout@v4

- name: Build and test
run: |
cmake --preset windows-release -DESL_ENABLE_CLANG_TIDY=OFF
cmake --preset windows-release -DESL_RUN_CLANG_TIDY_ON_BUILD=${{matrix.run_tidy}}
cmake --build --preset windows-release
ctest --preset windows-release
12 changes: 5 additions & 7 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"CMAKE_BUILD_TYPE": "Release",
"CPM_SOURCE_CACHE": "$env{CPM_SOURCE_CACHE}",
"ESL_USE_SANITIZER": "ASAN;UBSAN",
"ESL_ENABLE_CLANG_TIDY": "ON"
"ESL_RUN_CLANG_TIDY_ON_BUILD": "OFF"
}
},
{
Expand All @@ -25,8 +25,7 @@
"displayName": "Linux Dev",
"description": "Dev build on Linux",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"ESL_ENABLE_CLANG_TIDY": "OFF"
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
Expand All @@ -37,8 +36,8 @@
"cacheVariables": {
"CPM_SOURCE_CACHE": "$env{CPM_SOURCE_CACHE}",
"ESL_USE_SANITIZER": "",
"ESL_ENABLE_CLANG_TIDY": "ON",
"ESL_USE_MSVC_STATIC_ANALYSIS": "ON"
"ESL_RUN_CLANG_TIDY_ON_BUILD": "ON",
"ESL_USE_MSVC_PARALLEL_BUILD": "ON"
},
"condition": {
"type": "equals",
Expand All @@ -52,8 +51,7 @@
"displayName": "Windows Dev",
"description": "Dev build on Windows",
"cacheVariables": {
"ESL_ENABLE_CLANG_TIDY": "OFF",
"ESL_USE_MSVC_STATIC_ANALYSIS": "OFF"
"ESL_RUN_CLANG_TIDY_ON_BUILD": "OFF"
}
}
],
Expand Down
10 changes: 5 additions & 5 deletions cmake/clang_tidy.cmake
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@

option(ESL_ENABLE_CLANG_TIDY "Enable clang-tidy on build" OFF)
message(STATUS "ESL_ENABLE_CLANG_TIDY = ${ESL_ENABLE_CLANG_TIDY}")
option(ESL_RUN_CLANG_TIDY_ON_BUILD "Run clang-tidy on build" OFF)
message(STATUS "ESL_RUN_CLANG_TIDY_ON_BUILD = ${ESL_RUN_CLANG_TIDY_ON_BUILD}")

if(ESL_ENABLE_CLANG_TIDY)
if(ESL_RUN_CLANG_TIDY_ON_BUILD)
find_program(CLANG_TIDY_EXE
NAMES clang-tidy
DOC "Path to clang-tidy executable"
REQUIRED)
message(STATUS "Found clang-tidy = ${CLANG_TIDY_EXE}")
endif()

function(esl_apply_clang_tidy TARGET)
message(STATUS "Apply esl clang-tidy for ${TARGET}")
function(esl_apply_clang_tidy_on_build TARGET)
message(STATUS "Apply esl clang-tidy on build for ${TARGET}")

if(MSVC AND CMAKE_GENERATOR MATCHES "Visual Studio")
set_target_properties(${TARGET} PROPERTIES
Expand Down
31 changes: 0 additions & 31 deletions cmake/compiler_msvc.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

option(ESL_USE_MSVC_PARALLEL_BUILD "If enabled, build multiple files in parallel." ON)
option(ESL_USE_MSVC_STATIC_ANALYSIS "If enabled, run MSVC built-in static analysis and generate appropriate warnings" OFF)
option(ESL_USE_WIN32_LEAN_AND_MEAN "If enabled, define WIN32_LEAN_AND_MEAN" ON)

if(ESL_NOT_SUBPROJECT)
Expand All @@ -12,7 +11,6 @@ if(ESL_NOT_SUBPROJECT)
endif()

message(STATUS "ESL_USE_MSVC_PARALLEL_BUILD = ${ESL_USE_MSVC_PARALLEL_BUILD}")
message(STATUS "ESL_USE_MSVC_STATIC_ANALYSIS = ${ESL_USE_MSVC_STATIC_ANALYSIS}")
message(STATUS "ESL_USE_WIN32_LEAN_AND_MEAN = ${ESL_USE_WIN32_LEAN_AND_MEAN}")

function(esl_apply_common_compile_options TARGET)
Expand Down Expand Up @@ -51,32 +49,3 @@ function(esl_apply_msvc_parallel_build TARGET)
/MP
)
endfunction()

# To explicitly suppress spcific warnings:
# esl_apply_msvc_static_analysis(foobar
# WDL
# /wd6011
# )
function(esl_apply_msvc_static_analysis TARGET)
message(STATUS "Apply esl msvc static analysis for ${TARGET}")

set(multiValueArgs WDL)
cmake_parse_arguments(ARG "" "" "${multiValueArgs}" ${ARGN})

target_compile_options(${TARGET}
PRIVATE
/analyze

/wd6001 # Using uninitialized memory.
/wd6011 # Dereferencing potentially NULL pointer.

${ARG_WDL}
)

if (CMAKE_GENERATOR MATCHES "Visual Studio")
set_target_properties(${TARGET} PROPERTIES
VS_GLOBAL_EnableMicrosoftCodeAnalysis true
VS_GLOBAL_RunCodeAnalysis true
)
endif()
endfunction()
7 changes: 2 additions & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ target_link_libraries(esl_test

esl_apply_common_compile_options(esl_test)

if(ESL_ENABLE_CLANG_TIDY)
esl_apply_clang_tidy(esl_test)
if(ESL_RUN_CLANG_TIDY_ON_BUILD)
esl_apply_clang_tidy_on_build(esl_test)
endif()

if(ESL_USE_SANITIZER)
Expand All @@ -39,9 +39,6 @@ if(MSVC)
if(ESL_USE_MSVC_PARALLEL_BUILD)
esl_apply_msvc_parallel_build(esl_test)
endif()
if(ESL_USE_MSVC_STATIC_ANALYSIS)
esl_apply_msvc_static_analysis(esl_test)
endif()
endif()

get_target_property(test_FILES esl_test SOURCES)
Expand Down

0 comments on commit 4333f7a

Please sign in to comment.