[libc-commits] [PATCH] D144705: [libc] Add a linting target named "libc-lint".

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Fri Feb 24 00:34:42 PST 2023


sivachandra created this revision.
sivachandra added reviewers: lntue, michaelrj.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added projects: libc-project, All.
sivachandra requested review of this revision.

Lint targets for individual entrypoints have also been cleaned up. The
target "libc-lint" depends on the individual lint targets.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144705

Files:
  libc/CMakeLists.txt
  libc/cmake/modules/LLVMLibCObjectRules.cmake
  libc/test/src/CMakeLists.txt


Index: libc/test/src/CMakeLists.txt
===================================================================
--- libc/test/src/CMakeLists.txt
+++ libc/test/src/CMakeLists.txt
@@ -125,7 +125,7 @@
   add_custom_target(
     libc-api-test-tidy
     VERBATIM
-    COMMAND $<TARGET_FILE:clang-tidy> --system-headers
+    COMMAND ${LLVM_LIBC_CLANG_TIDY} --system-headers
       --checks=-*,llvmlibc-restrict-system-libc-headers
       "--extra-arg=-resource-dir=${COMPILER_RESOURCE_DIR}"
       --header-filter=.*
Index: libc/cmake/modules/LLVMLibCObjectRules.cmake
===================================================================
--- libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -598,9 +598,8 @@
         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 @@
       # 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)
Index: libc/CMakeLists.txt
===================================================================
--- libc/CMakeLists.txt
+++ libc/CMakeLists.txt
@@ -107,6 +107,7 @@
           The path to the clang-tidy binary can be set manually by passing
           -DLLVM_LIBC_CLANG_TIDY=<path/to/clang-tidy> to CMake.")
       endif()
+      add_custom_target(libc-lint)
     else()
       message(FATAL_ERROR "
         Linting is enabled but 'clang-tidy' is not found!


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144705.500097.patch
Type: text/x-patch
Size: 2373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230224/47e5d0ec/attachment.bin>


More information about the libc-commits mailing list