Closed aminya closed 1 year ago
Do you have --action_env specified?
No, as far as I have set. Maybe my dependencies set that. I can check and get back to you
I checked. I didn't specify that. I hope it can be fixed.
I have found a hacky workaround to hot patch the clang_tidy path using go-task
clang_tidy_path:
cmds:
- sed -i '/^clang-tidy "\$@"$/s|clang-tidy|{{.HOME}}/llvm/bin/clang-tidy -p {{.CWD}}|' {{.run_clang_tidy}}
preconditions:
- test -f {{.run_clang_tidy}}
vars:
run_clang_tidy: ./external/bazel_clang_tidy/clang_tidy/run_clang_tidy.sh
CWD:
sh: git rev-parse --show-toplevel
clang_tidy:
cmds:
- task: clang_tidy_path
- bazel build --config=tidy myproj
I run [compile_commands.json] extractor before running clang_tidy: https://github.com/hedronvision/bazel-compile-commands-extractor
You need to set the PATH correctly, and specify action_env accordingly, otherwise bazel will not find your custom tools. This is unrelated to this repo.
On Fri, May 6, 2022, 20:51 Amin Yahyaabadi @.***> wrote:
I checked. I didn't specify that. I hope it can be fixed.
I have found a hacky workaround to hot patch the clang_tidy path using go-task https://taskfile.dev/#/
clang_tidy_path: cmds:
- sed -i '/^clang-tidy "\$@"$/s|clang-tidy|{{.HOME}}/llvm/bin/clang-tidy/|' {{.run_clang_tidy}} preconditions:
test -f {{.run_clang_tidy}} vars: run_clang_tidy: ./bazel-myproj/external/bazel_clang_tidy/clang_tidy/run_clang_tidy.sh
tidy: cmds:
- task: clang_tidy_path
- bazel build --config=tidy myproj
— Reply to this email directly, view it on GitHub https://github.com/erenon/bazel_clang_tidy/issues/19#issuecomment-1119921323, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABOYM5GBHIMD7IXTFSAVI3VIVSZNANCNFSM5VGDERXA . You are receiving this because you commented.Message ID: @.***>
My PATH variable is already set. What should I specify in action_env? I cannot find anything in the documentation.
Here's the doc: https://docs.bazel.build/versions/main/command-line-reference.html#flag--action_env action_env should specify a path set that contains your custom clang tidy install.
If you are on macOS, see https://github.com/bazelbuild/bazel/issues/12049
We created a llvm_repo
repository rule to create an external repository and link the installed llvm directory into the llvm_repo
. This ensures bazel_clang_tidy can find clang-tidy and also makes the clang-tidy check reproducible.
Here is the related blog if anyone is interested.
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