From bfeef8b794da7510cd410c87ebc81e231c4450b3 Mon Sep 17 00:00:00 2001 From: Siva Chandra Reddy Date: Fri, 24 Feb 2023 08:27:29 +0000 Subject: [PATCH] [libc] Add a linting target named "libc-lint". Lint targets for individual entrypoints have also been cleaned up. The target "libc-lint" depends on the individual lint targets. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D144705 --- libc/CMakeLists.txt | 1 + libc/cmake/modules/LLVMLibCObjectRules.cmake | 11 +++++------ libc/test/src/CMakeLists.txt | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index ea5fa4f..743b241 100644 --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -107,6 +107,7 @@ if(LLVM_LIBC_ENABLE_LINTING) The path to the clang-tidy binary can be set manually by passing -DLLVM_LIBC_CLANG_TIDY= to CMake.") endif() + add_custom_target(libc-lint) else() message(FATAL_ERROR " Linting is enabled but 'clang-tidy' is not found! diff --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake index 9a3fc5a..652e97a 100644 --- a/libc/cmake/modules/LLVMLibCObjectRules.cmake +++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake @@ -598,9 +598,8 @@ function(create_entrypoint_object fq_target_name) COMMAND ${CMAKE_COMMAND} -E echo "Header file check skipped") endif() - set(lint_timestamp "${CMAKE_CURRENT_BINARY_DIR}/.${target_name}.__lint_timestamp__") - add_custom_command( - OUTPUT ${lint_timestamp} + add_custom_target( + ${fq_target_name}.__lint__ # --quiet is used to surpress warning statistics from clang-tidy like: # Suppressed X warnings (X in non-user code). # There seems to be a bug in clang-tidy where by even with --quiet some @@ -622,11 +621,11 @@ function(create_entrypoint_object fq_target_name) # use add_custom_command. This function requires an output file and since # linting doesn't produce a file, we create a dummy file using a # crossplatform touch. - COMMAND "${CMAKE_COMMAND}" -E touch ${lint_timestamp} - COMMENT "Linting... ${target_name}" - DEPENDS clang-tidy ${internal_target_name} ${ADD_ENTRYPOINT_OBJ_SRCS} + COMMENT "Linting... ${fq_target_name}" + DEPENDS ${internal_target_name} ${ADD_ENTRYPOINT_OBJ_SRCS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) + add_dependencies(libc-lint ${fq_target_name}.__lint__) endif() endfunction(create_entrypoint_object) diff --git a/libc/test/src/CMakeLists.txt b/libc/test/src/CMakeLists.txt index 2fe409c..87daefb 100644 --- a/libc/test/src/CMakeLists.txt +++ b/libc/test/src/CMakeLists.txt @@ -125,7 +125,7 @@ if(COMPILER_RESOURCE_DIR AND LLVM_LIBC_ENABLE_LINTING) add_custom_target( libc-api-test-tidy VERBATIM - COMMAND $ --system-headers + COMMAND ${LLVM_LIBC_CLANG_TIDY} --system-headers --checks=-*,llvmlibc-restrict-system-libc-headers "--extra-arg=-resource-dir=${COMPILER_RESOURCE_DIR}" --header-filter=.* -- 2.7.4