compile_commands.json generator for BazelThis repository contains two tools to generate a compile_commands.json file
from a Bazel workspace without the need to modify any of the Bazel configuration
files. This is the equivalent of CMAKE_EXPORT_COMPILE_COMMANDS from CMake for
Bazel.
The
Microsoft C/C++ Extension for Visual Studio Code
struggles sometimes with Bazel workspaces since not all include paths are at the
default locations. The compile_commands.json file can be used with clangd to
have a significant better LSP experience. For
Visual Studio Code (VS Code), the
clangd extension
can be used to utilize the project compile information via the
compile_commands.json file.
Invoke bazel-compile-commands //... to generate a compile_commands.json file
for the
Bazel label
//.... For more information, see
man 1 bazel-compile-commands.
The bazel-compile-commands command is ideal when you need a
compile_commands.json file instantly and don't require automatic updates of
the compile_commands.json file. For example in CI use cases when you when
static analysis tools use a compile_commands.json file as input.
bazel-compile-commandsInside a Bazel workspace run:
bazel-compile-commands
This will generate a compile_commands.json file in the current directory.
man 1 bazel-compile-commandsSee the .vscode/tasks.json file as an example on how
to integratebazel-compile-commands into VS Code.
bazel-compile-commands in the blog post
"compile_commands.json gallery",
Dec. 2, 2024.bazel build --config=gnu //bcc:bazel-compile-commands
To cross-compiling for a Linux aarch64 platform, run:
bazel build --platforms=//:linux_aarch64 --config=gnu //bcc:bazel-compile-commands
bazel build --config=cl //bcc:bazel-compile-commands
--spawn_strategy=local
Bazel flag.This source code is under the MIT license with the exceptions mentioned in "Third party source code in this repository".
C++
68.8%
Starlark
26.1%
Shell
3.1%
Python
1.4%
compile_commands.json generator for BazelThis repository contains two tools to generate a compile_commands.json file
from a Bazel workspace without the need to modify any of the Bazel configuration
files. This is the equivalent of CMAKE_EXPORT_COMPILE_COMMANDS from CMake for
Bazel.
The
Microsoft C/C++ Extension for Visual Studio Code
struggles sometimes with Bazel workspaces since not all include paths are at the
default locations. The compile_commands.json file can be used with clangd to
have a significant better LSP experience. For
Visual Studio Code (VS Code), the
clangd extension
can be used to utilize the project compile information via the
compile_commands.json file.
Invoke bazel-compile-commands //... to generate a compile_commands.json file
for the
Bazel label
//.... For more information, see
man 1 bazel-compile-commands.
The bazel-compile-commands command is ideal when you need a
compile_commands.json file instantly and don't require automatic updates of
the compile_commands.json file. For example in CI use cases when you when
static analysis tools use a compile_commands.json file as input.
bazel-compile-commandsInside a Bazel workspace run:
bazel-compile-commands
This will generate a compile_commands.json file in the current directory.
man 1 bazel-compile-commandsSee the .vscode/tasks.json file as an example on how
to integratebazel-compile-commands into VS Code.
bazel-compile-commands in the blog post
"compile_commands.json gallery",
Dec. 2, 2024.bazel build --config=gnu //bcc:bazel-compile-commands
To cross-compiling for a Linux aarch64 platform, run:
bazel build --platforms=//:linux_aarch64 --config=gnu //bcc:bazel-compile-commands
bazel build --config=cl //bcc:bazel-compile-commands
--spawn_strategy=local
Bazel flag.This source code is under the MIT license with the exceptions mentioned in "Third party source code in this repository".
C++
68.8%
Starlark
26.1%
Shell
3.1%
Python
1.4%