9.1 Compilation database definition
A compilation database (CDB) is a JSON file that specifies how each source file in a code base should be compiled. This JSON file is typically named compile
_commands.json
and resides in the root directory of a project. It provides a machine-readable record of all compiler invocations in the build process and is often used by various tools for more accurate analysis, refactoring, and more. Each entry in this JSON file typically contains the following fields:
directory: The working directory of the compilation.
command: The actual compile command, including compiler options.
arguments: Another field that can be used to specify compilation arguments. It contains the list of arguments.
file: The path to the source file being compiled.
output: The path to the output created by this compilation step.
As we can see from the fields description, there are two ways to specify compilation flags: using the command or arguments field. Let’s look at a specific...