From 80b45d47255a137f1c1fb9f407879c3696974d73 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Sun, 16 Oct 2022 14:30:13 -0600 Subject: [PATCH] Add custom target for running clang-tidy --- .clang-tidy | 14 ++++++++++++++ .github/workflows/ci.yml | 31 +++++++++++++++++++++++++++++++ CMakeLists.txt | 2 ++ 3 files changed, 47 insertions(+) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000..15f28d57 --- /dev/null +++ b/.clang-tidy @@ -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: '*' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 529a5488..a3437a41 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -134,3 +134,34 @@ jobs: - name: Check Formatting 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d157745..1e58fe51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -536,3 +536,5 @@ sfml_set_option(CLANG_FORMAT_EXECUTABLE clang-format STRING "Override clang-form add_custom_target(format COMMAND ${CMAKE_COMMAND} "-DCLANG_FORMAT_EXECUTABLE=${CLANG_FORMAT_EXECUTABLE}" -P ./cmake/Format.cmake WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" VERBATIM) + +add_custom_target(tidy COMMAND run-clang-tidy -p ${PROJECT_BINARY_DIR} VERBATIM)