From d7aeac3c61fb8c137518e2c620cca80c701bc75d Mon Sep 17 00:00:00 2001 From: Lior Stern Date: Wed, 1 Apr 2020 19:33:31 +0300 Subject: [PATCH] Add clang-tidy to build_tools/lint.fish --- CMakeLists.txt | 5 +++-- build_tools/lint.fish | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 25caca58c..5f9774ab0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ endif() include(cmake/Mac.cmake) project(fish) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # We are C++11. set(CMAKE_CXX_STANDARD 11) @@ -217,11 +218,11 @@ include(cmake/MacApp.cmake) # CMake does not support the "iquote" flag - https://gitlab.kitware.com/cmake/cmake/issues/15491 set(LINT_ARGS "-D$, -D>" "-I$, -I>") add_custom_target(lint - COMMAND build_tools/lint.fish -- ${LINT_ARGS} + COMMAND build_tools/lint.fish -p ${CMAKE_BINARY_DIR} -- ${LINT_ARGS} WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" ) add_custom_target(lint-all - COMMAND build_tools/lint.fish --all -- ${LINT_ARGS} + COMMAND build_tools/lint.fish --all -p ${CMAKE_BINARY_DIR} -- ${LINT_ARGS} WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" ) diff --git a/build_tools/lint.fish b/build_tools/lint.fish index f194c4324..f2315cd9f 100755 --- a/build_tools/lint.fish +++ b/build_tools/lint.fish @@ -13,7 +13,7 @@ set all no set kernel_name (uname -s) set machine_type (uname -m) -argparse a/all -- $argv +argparse a/all p/project= -- $argv # We only want -D and -I options to be passed thru to cppcheck. for arg in $argv @@ -117,6 +117,14 @@ if set -q c_files[1] # output will expect those messages to be written to stdout. oclint $c_files -- $argv 2>&1 end + + if type -q clang-tidy; and set -q _flag_project + echo + echo ======================================== + echo Running clang-tidy + echo ======================================== + clang-tidy -p $_flag_project $c_files + end else echo echo 'WARNING: No C/C++ files to check'