From 7a5116b1e1d6a5c649b0bfbd9baf689608c3f7b5 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 20 Nov 2026 10:30:17 +0100 Subject: 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. --- cmake/Modules/TidyHeaders.cmake | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) (limited to 'cmake/Modules') 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" -- cgit v1.2.3