Skip to content

Commit

Permalink
Add second way for running clang tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
a4z committed May 5, 2024
1 parent 1cd1414 commit 1e707d0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ if(PROJECT_IS_TOP_LEVEL)
USES_TERMINAL
)

add_custom_target(
clang_tidy
COMMAND ${CMAKE_SOURCE_DIR}/run_clang_tidy.sh ${CMAKE_CXX_STANDARD} ${CMAKE_BINARY_DIR}
COMMENT "Running clang-tidy on each file individually"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
USES_TERMINAL
)


add_custom_target(
clang-format
COMMAND git ls-files | grep -E ".*\\.(c|h|cpp|hpp)$" | xargs clang-format -i
Expand Down
7 changes: 7 additions & 0 deletions run_clang_tidy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

for file in $(git ls-files | grep -E '^(include|src)/.*\.(c|cpp|h|hpp)$')
do
echo 'Checking '$file
clang-tidy --extra-arg=-std=c++$1 -p $2 --header-filter='^$' $file || exit 255
done

0 comments on commit 1e707d0

Please sign in to comment.