compile_commands.json
The compile_commands.json
file helps you enable cross-references in your editor. Follow these instructions to place compile_commands.json
at the root of your repository.
Run the following to place compile_commands.json
at the root of your repository:
$ tools/bazel run //common:kernel_aarch64_compile_commands
Or, to place the file somewhere else, you may provide the absolute path to the destination as an argument to the script after --
:
$ tools/bazel run //common:kernel_aarch64_compile_commands -- /tmp/compile_commands.json
Use the option --real_clang_path
to update clang
's value of the "command"
's in the generated .json
with its absolute path.
$ tools/bazel run //common:kernel_aarch64_compile_commands -- --real_clang_path
If you want to build compile_commands.json
for in-tree modules, create a kernel_compile_commands
target with deps
set to the kernel_build
and external module targets (kernel_module
, ddk_module
and/or kernel_module_group
). Then tools/bazel run
the target.
See kernel_compile_commands
in documentation for all rules for details.
NOTE: For out-of-tree modules built with the kernel_module
macro, make sure your Makefile
files support the compile_commands.json
target.
See also the following links to incorporate clangd to your editor.
See the following for the schema of compile_commands.json
.