mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
devcontainer: Add clang-tidy, clang-tools, and clazy
Provide the analysis tools our CI images carry: `clang-tidy` to run the checks in `.clang-tidy`, `clang-tools` for `scan-build`, and `clazy`, the compiler our Clazy job builds with. Name the version of `clang-tidy` our checks are written against rather than install Ubuntu's unversioned package, which is a release behind and reports `cmake-use-cmsys-fstream` where it should not. `CMakeLists.txt` searches for `clang-tidy` only under the unversioned name, so link the version installed by name to it, as we already do for `clang-format`. `clazy` and `clang-tools` remain whatever versions Ubuntu carries rather than the ones the CI image does, so expect their diagnostics to differ from those jobs'. CMake's own clang-tidy checks are not available either way: `CMake_USE_CLANG_TIDY_MODULE` needs `Utilities/ClangTidyModule` built against Clang's development files, which are not installed here. Suggested-by: Tyler Yankee <tyler.yankee@kitware.com>
This commit is contained in:
@@ -36,6 +36,21 @@ ninja-build
|
||||
gdb
|
||||
valgrind
|
||||
|
||||
# Analyze CMake. `clazy` is the compiler our Clazy CI job builds with,
|
||||
# `clang-tools` provides `scan-build`, and `clang-tidy` runs the checks in
|
||||
# `.clang-tidy`. Name the version of `clang-tidy` our checks are written
|
||||
# against: `Utilities/ClangTidyModule` tracks the Clang release our CI image
|
||||
# carries, and older versions report `cmake-use-cmsys-fstream` where they
|
||||
# should not. Ubuntu's unversioned `clang-tidy` package is a release behind.
|
||||
# `clazy` and `clang-tools` are whatever versions Ubuntu carries, so expect
|
||||
# their diagnostics to differ from those jobs'. CMake's own checks are not
|
||||
# among them either way: `CMake_USE_CLANG_TIDY_MODULE` needs
|
||||
# `Utilities/ClangTidyModule` built against Clang's development files, which
|
||||
# are not installed here.
|
||||
clang-tidy-22
|
||||
clang-tools
|
||||
clazy
|
||||
|
||||
# Build the documentation.
|
||||
python3-sphinx
|
||||
|
||||
|
||||
@@ -23,5 +23,8 @@ dpkg-reconfigure --frontend=noninteractive locales
|
||||
|
||||
# `Utilities/Scripts/clang-format.bash` finds `clang-format-18` by name, but
|
||||
# make the unversioned name resolve to version 18 as well so that tools
|
||||
# looking for it get the version our style rules require.
|
||||
# looking for it get the version our style rules require. `CMakeLists.txt`
|
||||
# searches for `clang-tidy` only under the unversioned name, so the version
|
||||
# installed by name needs one too.
|
||||
ln -s "$(command -v clang-format-18)" /usr/local/bin/clang-format
|
||||
ln -s "$(command -v clang-tidy-22)" /usr/local/bin/clang-tidy
|
||||
|
||||
@@ -159,6 +159,22 @@ against, the container provides:
|
||||
$ cmake --build build-asan
|
||||
$ ctest --test-dir build-asan
|
||||
|
||||
* ``clang-tidy``, ``scan-build``, and ``clazy``, the compiler our Clazy CI
|
||||
job builds with, to analyze CMake rather than only compile it:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ cmake -G Ninja -B build-tidy -S . -DCMake_RUN_CLANG_TIDY=ON
|
||||
$ cmake -G Ninja -B build-clazy -S . -DCMAKE_CXX_COMPILER=clazy
|
||||
|
||||
``clang-tidy`` is the version our checks are written against, which is
|
||||
not the one Ubuntu's unversioned package provides. ``scan-build`` and
|
||||
``clazy`` are whatever versions Ubuntu carries rather than the ones our
|
||||
CI image does, so expect their diagnostics to differ from those jobs'.
|
||||
CMake's own checks are not available either way:
|
||||
``CMake_USE_CLANG_TIDY_MODULE`` needs `Utilities/ClangTidyModule`_ built
|
||||
against Clang's development files, which the container does not install.
|
||||
|
||||
* ``glab``, the `GitLab CLI`_, to work with merge requests, issues, and
|
||||
pipelines on our GitLab instance, and `glab-axi`_, a wrapper around it
|
||||
whose output follows the `AXI`_ conventions:
|
||||
@@ -173,6 +189,7 @@ against, the container provides:
|
||||
.. _`Kitware APT repository`: https://apt.kitware.com
|
||||
.. _`C++ Code Style`: source.rst#c-code-style
|
||||
.. _`.pre-commit-config.yaml`: ../../.pre-commit-config.yaml
|
||||
.. _`Utilities/ClangTidyModule`: ../../Utilities/ClangTidyModule
|
||||
.. _`CMake Documentation Guide`: documentation.rst
|
||||
.. _`CMake Debugging Guide`: debug.rst
|
||||
.. _`GitLab CLI`: https://docs.gitlab.com/editor_extensions/gitlab_cli/
|
||||
|
||||
Reference in New Issue
Block a user