rizsotto / Bear

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

[Suggestion] Set drop_output_field to true by default #371

Closed chouzz closed 3 years ago

chouzz commented 3 years ago

Currently, bear 3.x set drop_output_field to false, the compile_commands.json file will contain “output” filed. However, the output field usually does not appear in cmake exported compile_commands.json, and bear2.x also turns off output by default. So I think it would be better set drop_output_field to true by default.

rizsotto commented 3 years ago

Hey @chouzz thanks for your suggestion.

The JSON compilation database spec does not say anything about defaults. I consider that documentation is the north-star, independently how other tools implementing the spec (or what is the default values of those tools).

By emitting the output field, it can be used as a "key" or "primary key" of the generated database. Which helps to detect duplicate entries when the users are using --append flag... Because one of the problem with the --append flag, when the build file changes the compiler flags it might include duplicate entries. Here it helps to have the output field enabled by default.