Skip to main content

Extending Bear

Goal

Learn how to extend Bear to support additional compilers

Bear compiler support is currently limited to GNU, Intel, and LLVM compilers. However, it can be extended with relatively little effort.

To add support for an additional compiler, use the --config option to specify a configuration file that includes the path to the compiler binary.

For example, to add support for the crayftn compiler, the following config file bear.config can be used:

{
"compilation":
{
"compilers_to_recognize": [
{
"executable": "/path/to/bin/crayftn",
"flags_to_add": [],
"flags_to_remove": []
}],
"compilers_to_exclude": []
},
"output":
{
"content":
{
"include_only_existing_source": true,
"paths_to_include": [],
"paths_to_exclude": [],
"duplicate_filter_fields": "file_output"
},
"format":
{
"command_as_array": true,
"drop_output_field": false
}
}
}

Then execute bear as usual, but adding the --config argument, e.g.:

bear --config bear.config -- make