title: How to generate compile_commands.json for a C++ Bazel project
body: <p>In a C++ <a href="https://docs.bazel.build/versions/master/tutorial/cpp.html" rel="noreferrer">Bazel</a> project, I want to use tools like <a href="https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html" rel="noreferrer">Clang Tools</a> or <a href="https://github.com/Andersbakken/rtags" rel="noreferrer">RTags</a>, etc.</p>
  
  <p>For that I need to generate a <a href="https://clang.llvm.org/docs/JSONCompilationDatabase.html" rel="noreferrer">compile_commands.json</a> file.</p>
  
  <p>The solution is trivial for CMake with the <a href="https://cmake.org/cmake/help/v3.5/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html" rel="noreferrer">CMAKE_EXPORT_COMPILE_COMMANDS</a>. </p>
  
  <p>For simple Makefiles you can still use the <a href="https://github.com/rizsotto/Bear" rel="noreferrer">Bear</a> tool.</p>
  
  <p>However AFAIK there is no built-in solution for C++ Bazel projects.</p>