erenon / bazel_clang_tidy

Run clang-tidy on Bazel C++ targets directly, efficiently, with caching enabled
MIT License
109 stars 58 forks source link

How do you run clang-tidy without building targets? #34

Closed luxe closed 1 year ago

luxe commented 1 year ago

One of the features mentioned is:

erenon commented 1 year ago

I checked this on a fresh clone of this repo:

bazel_clang_tidy$ bazel build //example --aspects clang_tidy/clang_tidy.bzl%clang_tidy_aspect --output_groups=report -s
INFO: Analyzed target //example:example (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
SUBCOMMAND: # //example:example [action 'Run clang-tidy on example/app.cpp', configuration: 8960923b9e7dc13418be101268efd8e57d80283213d18174705345598b699c6b, execution platform: @local_config_platform//:host]
(cd /home/erenon/.cache/bazel/_bazel_erenon/9363d386014256f013f90f7416fb48e9/execroot/__main__ && \
  exec env - \
    PATH=/usr/local/sbin:/usr/local/bin:/usr/bin \
  bazel-out/k8-fastbuild/bin/clang_tidy/clang_tidy clang-tidy bazel-out/k8-fastbuild/bin/example/bazel_clang_tidy_example/app.cpp.example.clang-tidy.yaml --export-fixes bazel-out/k8-fastbuild/bin/example/bazel_clang_tidy_example/app.cpp.example.clang-tidy.yaml example/app.cpp -- -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -iquote . -iquote bazel-out/k8-fastbuild/bin -iquote external/bazel_tools -iquote bazel-out/k8-fastbuild/bin/external/bazel_tools)
# Configuration: 8960923b9e7dc13418be101268efd8e57d80283213d18174705345598b699c6b
# Execution platform: @local_config_platform//:host
INFO: From Run clang-tidy on example/app.cpp:
12304 warnings generated.
Suppressed 12304 warnings (12304 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
Aspect //clang_tidy:clang_tidy.bzl%clang_tidy_aspect of //example:example up-to-date:
  bazel-bin/example/bazel_clang_tidy_example/app.cpp.example.clang-tidy.yaml
INFO: Elapsed time: 2.261s, Critical Path: 1.99s
INFO: 5 processes: 4 internal, 1 linux-sandbox.
INFO: Build completed successfully, 5 total actions

It did run clang-tidy only, not CXX - as expected. Can you provide an example that reproduces your issue?

luxe commented 1 year ago

Thanks, I thought aspects ran alongside the normal build graph. Now I wonder how to run both the aspect and the normal build in parallel

erenon commented 1 year ago
$ bazel build //example --aspects clang_tidy/clang_tidy.bzl%clang_tidy_aspect --output_groups=report,default