Add custom target for running clang-tidy

This commit is contained in:
Chris Thrasher 2022-10-16 14:30:13 -06:00
parent 3d02d490bd
commit 80b45d4725
3 changed files with 47 additions and 0 deletions

14
.clang-tidy Normal file
View File

@ -0,0 +1,14 @@
Checks: >
-*,
clang-analyzer-*,
-clang-analyzer-core.NonNullParamChecker,
-clang-analyzer-core.NullDereference,
-clang-analyzer-nullability.NullablePassedToNonnull,
-clang-analyzer-optin.cplusplus.VirtualCall,
-clang-analyzer-optin.osx.*,
-clang-analyzer-optin.portability.UnixAPI,
-clang-analyzer-osx.*,
-clang-analyzer-security.insecureAPI.rand,
-clang-analyzer-unix.Malloc,
HeaderFilterRegex: '.*'
WarningsAsErrors: '*'

View File

@ -134,3 +134,34 @@ jobs:
- name: Check Formatting - name: Check Formatting
run: git diff --exit-code run: git diff --exit-code
tidy:
name: Analyzing on ${{ matrix.platform.name }}
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- { name: Linux, os: ubuntu-latest }
- { name: macOS, os: macos-12 }
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Install Linux Dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install libxrandr-dev libxcursor-dev libudev-dev libopenal-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev
- name: Install macOS Dependencies
if: runner.os == 'macOS'
run: |
brew install llvm
echo /usr/local/opt/llvm/bin >> $GITHUB_PATH
- name: Configure
run: cmake -S $GITHUB_WORKSPACE -B $GITHUB_WORKSPACE/build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DSFML_BUILD_EXAMPLES=TRUE -DSFML_BUILD_TEST_SUITE=TRUE
- name: Analyze Code
run: cmake --build $GITHUB_WORKSPACE/build --target tidy

View File

@ -536,3 +536,5 @@ sfml_set_option(CLANG_FORMAT_EXECUTABLE clang-format STRING "Override clang-form
add_custom_target(format add_custom_target(format
COMMAND ${CMAKE_COMMAND} "-DCLANG_FORMAT_EXECUTABLE=${CLANG_FORMAT_EXECUTABLE}" -P ./cmake/Format.cmake COMMAND ${CMAKE_COMMAND} "-DCLANG_FORMAT_EXECUTABLE=${CLANG_FORMAT_EXECUTABLE}" -P ./cmake/Format.cmake
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" VERBATIM) WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" VERBATIM)
add_custom_target(tidy COMMAND run-clang-tidy -p ${PROJECT_BINARY_DIR} VERBATIM)