rizsotto / Bear

Bear is a tool that generates a compilation database for clang tooling.
GNU General Public License v3.0
4.76k stars 312 forks source link

[enhancements] add support for "-include foo.h" flag #466

Closed afm0901x closed 2 years ago

afm0901x commented 2 years ago

Describe the bug GCC and Clang have a flag to include header file before the parsing step.

To Reproduce Clangd already aware of this flag, I got it working by manually injecting "-include foo.h" to arguments block in compile_commands.json:

...
"arguments": [
    "/usr/bin/gcc",
    "-I../include",
    "-I/usr/include/bar/bar-2",
    "-include../foo.h",
...

Expected behavior Bear to add -include flag to compile_commands.json.

Environment:

rizsotto commented 2 years ago

Hey @afm0901x , this functionality is already implemented. You can remove or add flags to the compilation database entries.

Read the man citnames config file section to see how to set it up. This config can be passed to Bear as --config ....