6.1.2.7. CompileCommandsIntegration¶
Use compile_commands.json database for analysis compilation
This rule uses a compile_commands.json file for the analysis
compilation and corresponds to the command-line tool
build_compile_commands.
Such files can be generated e.g. when using CMake and supplying the option
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON, build inspection tools like
bear, some code editor extensions, and quite some more.
As a compile_commands.json does not contain internal project
structure, all files are compiled and then linked together. This is most
likely correct for small projects, but for larger projects this could contain
unwanted files (e.g. CMake test compilations, etc.). In such a case you will
have to use exclude_pattern and/or
include_pattern to select the desired files.
Options¶
The following places define options that affect this rule: BuildSystemIntegration, Project-GlobalOptions
abort_on_error¶
abort_on_error : bool = True
capture_output¶
capture_output : bool = False
The output will be parsed according to the format configured with the options output_format, stdout_format, stderr_format.
compile_commands_json¶
compile_commands_json : bauhaus.analysis.config.PlainPath = 'None (value must be set)'
compile_commands.json file to use for analysis compilation
(interpreted relative to /Project/directory, or
cwd if set).
compiler_config¶
compiler_config : bauhaus.analysis.config.PlainPath | None = None
Write the compiler toolchain profile to the configured layer. This only has an effect if setup_compiler_config is set to true.
You have to make sure that the layer is an active layer as otherwise the profile will get written but does not have any effect.
cwd¶
cwd : bauhaus.analysis.config.ProjectRelativePath | None = None
Directory for execution of tool build_compile_commands. Defaults to the
/Project/directory if left unspecified.
environment¶
environment : dict[str, str] = {}
Environment for calling tool build_compile_commands.
These entries are added to the environment and existing ones will be overwritten.
exclude_pattern¶
exclude_pattern : set[bauhaus.analysis.config.FileGlobPattern] = set()
Exclude files matching globbing pattern from analysis compilation.
The pattern is applied to the individual "file" attributes inside the
compile_commands.json, therefore the pattern has to be specified
accordingly (i.e. matching absolute path vs. matching relative path).
include_pattern¶
include_pattern : set[bauhaus.analysis.config.FileGlobPattern] = set()
Limit analysis compilation to files matching globbing pattern.
The pattern is applied to the individual "file" attributes inside the
compile_commands.json, therefore the pattern has to be specified
accordingly (i.e. matching absolute path vs. matching relative path).
ir¶
ir : bauhaus.analysis.config.PlainPath | None = None
Name of the IR file to create. If left unspecified, the one specified as /Project/ir will be used.
If specified, it is interpreted relative to /Project/directory (or cwd if set).
options¶
options : str | None = None
Additional command-line options to pass to tool build_compile_commands.
output_format¶
output_format : list[str] = ['generic']
The format names available here correspond to the provider
options in /Analysis/AnalysisControl/ExternalAnalysisFormats.
This option only has an effect if capture_output is true.
setup_compiler_config¶
setup_compiler_config : bool = False
If set to true, attempt to detect the C/C++ compiler used and invoke the appropriate
setup tool (like gccsetup, clangsetup, etc.) in order to
configure the compiler toolchain profile automatically.
If compiler_config is not set, use the most local layer to write the configuration to.
stderr_format¶
stderr_format : list[str] = []
The format names available here correspond to the provider
options in /Analysis/AnalysisControl/ExternalAnalysisFormats.
This option only has an effect if capture_output is true.
stdout_format¶
stdout_format : list[str] = []
The format names available here correspond to the provider
options in /Analysis/AnalysisControl/ExternalAnalysisFormats.
This option only has an effect if capture_output is true.