From f50c11d39c0233a82e8de406f354b518edfa9b29 Mon Sep 17 00:00:00 2001 From: Arseniy Obolenskiy Date: Wed, 29 Jan 2025 09:18:59 +0100 Subject: [PATCH] [CPU] Enable clang-tidy-18 checks on Ubuntu 24.04 --- .github/dockerfiles/docker_tag | 2 +- .../ov_build/ubuntu_24_04_x64/Dockerfile | 12 ++++++++++++ .github/workflows/ubuntu_24.yml | 3 +++ .../clang_tidy/clang_tidy.cmake | 16 ++++++++-------- cmake/developer_package/plugins/plugins.cmake | 3 ++- 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/.github/dockerfiles/docker_tag b/.github/dockerfiles/docker_tag index 0d2fd1b31c0f73..37db3d46f34033 100644 --- a/.github/dockerfiles/docker_tag +++ b/.github/dockerfiles/docker_tag @@ -1 +1 @@ -pr-28040 +pr-28725 diff --git a/.github/dockerfiles/ov_build/ubuntu_24_04_x64/Dockerfile b/.github/dockerfiles/ov_build/ubuntu_24_04_x64/Dockerfile index 82a51ffc0b175e..bc72500dde74a1 100644 --- a/.github/dockerfiles/ov_build/ubuntu_24_04_x64/Dockerfile +++ b/.github/dockerfiles/ov_build/ubuntu_24_04_x64/Dockerfile @@ -31,6 +31,12 @@ RUN apt-get update && \ python3-full \ # For Java API default-jdk \ + # Compiler \ + clang-18 \ + # Static analyzer + clang-tidy-18 \ + # clang-tidy uses clang-format as a dependency + clang-format-18 \ && \ rm -rf /var/lib/apt/lists/* @@ -40,6 +46,12 @@ RUN chmod +x /install_build_dependencies.sh && \ /install_build_dependencies.sh && \ rm -rf /var/lib/apt/lists/* +RUN update-alternatives --install /usr/bin/clang-format clang-format $(which clang-format-18) 100 && \ + update-alternatives --set clang-format $(which clang-format-18) + +RUN update-alternatives --install /usr/bin/clang-tidy clang-tidy $(which clang-tidy-18) 100 && \ + update-alternatives --set clang-tidy $(which clang-tidy-18) + # Install sccache ARG SCCACHE_VERSION="v0.7.5" ENV SCCACHE_HOME="/opt/sccache" \ diff --git a/.github/workflows/ubuntu_24.yml b/.github/workflows/ubuntu_24.yml index beac15bfbda97d..61e82a2645a486 100644 --- a/.github/workflows/ubuntu_24.yml +++ b/.github/workflows/ubuntu_24.yml @@ -88,9 +88,12 @@ jobs: build-js: true build-debian-packages: true build-contrib: true + # clang-tidy static analysis check is enabled as part of collection + # to avoid an additional separate build execution cmake-options: |- -G "Ninja Multi-Config" \ -DENABLE_CPPLINT=OFF \ + -DENABLE_CLANG_TIDY=ON \ -DENABLE_NCC_STYLE=OFF \ -DENABLE_TESTS=ON \ -DENABLE_STRICT_DEPENDENCIES=OFF \ diff --git a/cmake/developer_package/clang_tidy/clang_tidy.cmake b/cmake/developer_package/clang_tidy/clang_tidy.cmake index f3b3a6e697e0cd..abad5c6f880c54 100644 --- a/cmake/developer_package/clang_tidy/clang_tidy.cmake +++ b/cmake/developer_package/clang_tidy/clang_tidy.cmake @@ -3,23 +3,23 @@ # if(ENABLE_CLANG_TIDY) - set(CLANG_TIDY_REQUIRED_VERSION 15 CACHE STRING "clang-tidy version to use") - set(CLANG_TIDY_FILENAME clang-tidy-${CLANG_TIDY_REQUIRED_VERSION} clang-tidy) + set(CLANG_TIDY_REQUIRED_VERSION 15 CACHE STRING "Minimum clang-tidy version to use") + set(CLANG_TIDY_FILENAME clang-tidy) find_host_program(CLANG_TIDY NAMES ${CLANG_TIDY_FILENAME} PATHS ENV PATH) if(CLANG_TIDY) - execute_process(COMMAND ${CLANG_TIDY} ${CMAKE_CURRENT_SOURCE_DIR} ARGS --version OUTPUT_VARIABLE CLANG_VERSION) + execute_process(COMMAND ${CLANG_TIDY} --version OUTPUT_VARIABLE CLANG_VERSION) if(NOT CLANG_VERSION) - message(WARNING "Supported clang-tidy version is ${CLANG_TIDY_REQUIRED_VERSION}!") + message(WARNING "Minimum supported clang-tidy version is ${CLANG_TIDY_REQUIRED_VERSION}!") set(ENABLE_CLANG_TIDY OFF) else() - string(REGEX REPLACE "[^0-9]+([0-9]+)\\..*" "\\1" CLANG_TIDY_MAJOR_VERSION ${CLANG_VERSION}) - if(NOT CLANG_TIDY_MAJOR_VERSION EQUAL CLANG_TIDY_REQUIRED_VERSION) - message(WARNING "Supported clang-tidy version is ${CLANG_TIDY_REQUIRED_VERSION}! Provided version ${CLANG_TIDY_MAJOR_VERSION}") + string(REGEX REPLACE ".*version ([0-9]+)\\..*" "\\1" CLANG_TIDY_MAJOR_VERSION ${CLANG_VERSION}) + if(CLANG_TIDY_MAJOR_VERSION LESS CLANG_TIDY_REQUIRED_VERSION) + message(WARNING "Minimum supported clang-tidy version is ${CLANG_TIDY_REQUIRED_VERSION}! Provided version ${CLANG_TIDY_MAJOR_VERSION}") set(ENABLE_CLANG_TIDY OFF) endif() endif() else() - message(WARNING "Supported clang-tidy-${CLANG_TIDY_REQUIRED_VERSION} is not found!") + message(WARNING "clang-tidy is not found!") set(ENABLE_CLANG_TIDY OFF) endif() endif() diff --git a/cmake/developer_package/plugins/plugins.cmake b/cmake/developer_package/plugins/plugins.cmake index b7664557cec3d8..19ccacd0310522 100644 --- a/cmake/developer_package/plugins/plugins.cmake +++ b/cmake/developer_package/plugins/plugins.cmake @@ -108,7 +108,8 @@ function(ov_add_plugin) if (OV_PLUGIN_ADD_CLANG_TIDY) if (ENABLE_CLANG_TIDY) - set_target_properties(${OV_PLUGIN_NAME} PROPERTIES CXX_CLANG_TIDY clang-tidy-${CLANG_TIDY_REQUIRED_VERSION}) + set_target_properties(${OV_PLUGIN_NAME} PROPERTIES + CXX_CLANG_TIDY "clang-tidy;--extra-arg=-Wno-unused-command-line-argument") endif() endif()