How to generate compile_commands.json for a C++ Bazel project

Viewed 20077
2 Answers

To add to the alternatives listed by other answers...

Hedron's Compile Commands Extractor for Bazel (GitHub) was just released and does what you want, I think. From the README, its goal is to "provide Bazel users cross-platform autocomplete for (Objective-)C(++) to make development more efficient and fun[..., and] export Bazel build actions into the compile_commands.json format that enables great tooling decoupled from Bazel."

Disclaimer: I work for the company that makes hedronvision/bazel-compile-commands-extractor... but I use it every day, and in my personal opinion it is very good!

Related