bazel_clang_tidy
bazel_clang_tidy copied to clipboard
Run clang-tidy on Bazel C++ targets directly, efficiently, with caching enabled
always report `error: invalid argument '-std=c++17' not allowed with 'C' [clang-diagnostic-error] /root/.cache/bazel/_bazel_root/c0cc7bb48e68379f59a785b3d4b8baaf/execroot/__main__/bazel-out/k8-fastbuild/bin/external/com_github_google_glog/_virtual_includes/glog/glog/logging.h:42:10: error: 'iosfwd' file not found [clang-diagnostic-error] #include ` @erenon
clang-tidy is not found in run_clang_tidy.sh although it is on the PATH. It seems that the spawn doesn't pass the env variables. https://github.com/erenon/bazel_clang_tidy/blob/783aa523aafb4a6798a538c61e700b6ed27975a7/clang_tidy/run_clang_tidy.sh#L14
bazel-compile-commands-extractor can generate compiled_commands.json files. I tried to hot patch the shell binary and add [`-p $PROJECT_ROOT` to the clang-tidy command](https://github.com/erenon/bazel_clang_tidy/issues/19#issuecomment-1119921323). However, it seems that still clang-tidy fails to find...
` root@324072f8380a:~/test/bazel_clang_tidy# bazel build //example --aspects clang_tidy/clang_tidy.bzl%clang_tidy_aspect --output_groups=report Starting local Bazel server and connecting to it... INFO: Analyzed target //example:example (19 packages loaded, 89 targets configured). INFO: Found 1 target......
`bazel build //main:hello-world --config clang-tidy` `DEBUG: Rule 'bazel_clang_tidy' indicated that a canonical reproducible form can be obtained by modifying arguments shallow_since = "1620650326 +0800" DEBUG: Repository bazel_clang_tidy instantiated at: /root/test/2clang_tidy_test/WORKSPACE:7:15:...
Bazel can't cache the fetch, as documented: https://bazel.build/docs/external > Prefer [http_archive](https://bazel.build/rules/lib/repo/http#http_archive) to git_repository and new_git_repository. The reasons are: > ... > http_archive works with the [repository cache](https://bazel.build/docs/build#repository-cache), but not git_repository....
Currently I invoke this project as documented, with a command similar to ``` bazel build --keep_going \ --aspects //lint/clang_tidy:clang_tidy.bzl%clang_tidy_aspect \ --output_groups=report \ -- //... ``` The downside to this is...
Header files, which are not exposed, are not checked by clang-tidy via bazel_clang_tidy. e.g. ```bzl cc_library( name="test", srcs=["*.cpp"], #
Hi, how can you turn on --fix with clang-tidy
Hey all! I made some local changes to get this to work with our macOS toolchain. The PR can't be uploaded like this, but I'm happy to work with you...