c++ - 如何为 C++ Bazel 项目生成 compile_commands.json

标签 c++ bazel

在 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 上,您可以找到:

关于c++ - 如何为 C++ Bazel 项目生成 compile_commands.json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44966133/

相关文章:

c++ - 一秒钟后 Win32 控制台消失

ubuntu-16.04 - sudo apt-get 更新 Ubuntu 16.04 时出现 Bazel key 过期错误

Bazel 选择特定 GCC 主要版本的条件

macos - 构建@com_google_protobuf 时缺少依赖项//:protobuf_lite

c++ - 为什么我年龄不正确

c++ - 了解纯虚函数

python - 在 Python 中从 SWIG 实例化 shared_ptr 对象

c++ - 有没有办法让 VS C++ 自动完成更简单?

node.js - Bazel 与 lerna 和 yarn 工作区一起使用

typescript - 通过 bazel 执行 Jasmine 测试时未找到规范