diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-11-20 10:30:17 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-11-20 10:30:17 +0100 |
| commit | 7a5116b1e1d6a5c649b0bfbd9baf689608c3f7b5 (patch) | |
| tree | df9c9df33cdc1b26957138dd50ed5539582710db /cmake/Modules | |
| parent | 01805b0a7b78e4eed2c30f5c34e0044a0b240634 (diff) | |
| download | kernel-7a5116b1e1d6a5c649b0bfbd9baf689608c3f7b5.tar.xz kernel-7a5116b1e1d6a5c649b0bfbd9baf689608c3f7b5.zip | |
build: ensure clang-tidy uses the correct paths
Previously, clang-tidy would fall back to the global GCC toolchain and
its include paths, meaning that any custom patches would be ignored. A
partial solution had already been implemented for header checks, but
the regular cpp file checks did not use the new flags.
This change extracts the GCC toolchain location determination into the
platform's CMake toolchain file and then applies those flags to both
header and cpp file checks consistently.
Diffstat (limited to 'cmake/Modules')
| -rw-r--r-- | cmake/Modules/TidyHeaders.cmake | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/cmake/Modules/TidyHeaders.cmake b/cmake/Modules/TidyHeaders.cmake index 931da860..0ae5b218 100644 --- a/cmake/Modules/TidyHeaders.cmake +++ b/cmake/Modules/TidyHeaders.cmake @@ -4,31 +4,11 @@ function(teachos_tidy_headers) endif() set(ROOTS "kapi" "kernel" "libs") - set(TIDY_EXTRA_ARGS) if(CMAKE_CROSSCOMPILING) list(APPEND ROOTS "arch/${CMAKE_SYSTEM_PROCESSOR}") - separate_arguments(COMPILER_FLAGS NATIVE_COMMAND "${CMAKE_CXX_FLAGS}") - execute_process( - COMMAND "${CMAKE_CXX_COMPILER}" ${COMPILER_FLAGS} "-E" "-x" "c++" "-v" "/dev/null" - OUTPUT_QUIET - ERROR_VARIABLE COMPILER_OUTPUT - RESULT_VARIABLE COMPILER_RESULT - ) - - if(COMPILER_RESULT EQUAL 0 AND COMPILER_OUTPUT MATCHES "#include <\\.\\.\\.> search starts here:\n(.*)\nEnd of search list") - string(REPLACE "\n" ";" COMPILER_INCLUDE_LINES "${CMAKE_MATCH_1}") - foreach(LINE IN LISTS COMPILER_INCLUDE_LINES) - string(STRIP "${LINE}" DIRECTORY) - if(IS_DIRECTORY "${DIRECTORY}") - get_filename_component(DIRECTORY "${DIRECTORY}" REALPATH) - list(APPEND TIDY_EXTRA_ARGS "--extra-arg=-isystem" "--extra-arg=${DIRECTORY}") - endif() - endforeach() - endif() - - if(NOT TIDY_EXTRA_ARGS) + if(NOT CLANG_TIDY_EXTRA_ARGS) message(WARNING "Could not determine the system include directories of ${CMAKE_CXX_COMPILER}, header checks will likely fail") endif() endif() @@ -54,7 +34,7 @@ function(teachos_tidy_headers) "-p" "${PROJECT_BINARY_DIR}" "--quiet" "--checks=-*,misc-include-cleaner" - ${TIDY_EXTRA_ARGS} + ${CLANG_TIDY_EXTRA_ARGS} "${HEADER}" COMMAND "${CMAKE_COMMAND}" "-E" "touch" "${STAMP}" DEPENDS "${HEADER}" "${PROJECT_SOURCE_DIR}/.clang-tidy" |
