README: Document compile_commands.json.

This commit is contained in:
Arkadiusz Hiler 2023-09-20 17:12:17 +03:00
parent 90cc4f1075
commit 2e817dc4f6

View File

@ -219,6 +219,42 @@ script `wine/tools/gdbinit.py` (source it) that provides `load-symbol-files`
(or `lsf` for short) command which loads the symbols for all the mapped files. (or `lsf` for short) command which loads the symbols for all the mapped files.
`compile_commands.json`
-----------------------
For use with [clangd](https://clangd.llvm.org/) LSP server and similar tooling.
Projects built using cmake or meson (e.g. vkd3d-proton) automatically come with
`compile_commands.json`. For autotools (e.g. wine) you have to [configure the
build](#configuring-the-build) with `--enable-bear` that uses
[bear](https://github.com/rizsotto/Bear) to create the compilation database.
It's not on by default as it make the build slightly slower.
The build system collects all the created compile_commands.json files in a
build subdirectory named `compile_commands/`.
The paths are translated to point to the real source (i.e. not the rsynced
copy). It still may depend on build directory for things like auto-generated
`config.h` though and for wine it may be beneficial to run `tools/make_requests`
in you source directories as those changes are not committed.
You can then configure your editor to use that file for clangd in a few ways:
1) directly - some editors/plugins allow you to specify the path to `compile_commands.json`
2) via `.clangd` file, e.g.
```bash
cd src/proton/wine/
cat > .clangd <<EOF
CompileFlags:
CompilationDatabase: ../build/current-dev/compile_commands/wine64/
EOF
```
3) by symlinking:
```bash
ln -s ../build/current-dev/compile_commands/wine64/compile_commands.json .
```
Runtime Config Options Runtime Config Options
---------------------- ----------------------