在 C++ 中 Bazel项目,我想使用像 Clang Tools 这样的工具或 RTags等
为此我需要生成一个 compile_commands.json文件。
使用 CMAKE_EXPORT_COMPILE_COMMANDS 的 CMake 解决方案很简单.
对于简单的 Makefile,您仍然可以使用 Bear工具。
但是据我所知,没有针对 C++ Bazel 项目的内置解决方案。
最佳答案
额外信息:
- Bear 目前没有使用 Bazel:this issue
- 可以找到有关 compile_command.json 的良好文档 here .
建议的解决方案:
谷歌搜索后我找到了gist:Basics of generating a compile_commands.json file with Bazel .
它工作正常,我已经写了 an automated solution with bash scripts <- 我的解决方案
备选方案:
同样在 GitHub 上,您可以找到:
- Kythe:使用 Bazel Action 监听器
- github.com/grailbio/bazel-compilation-database:提供脚本和 bazel 规则。
关于c++ - 如何为 C++ Bazel 项目生成 compile_commands.json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44966133/