ThrowTheSwitch / Ceedling

Ruby-based unit testing and build system for C projects
http://throwtheswitch.org
Other
586 stars 246 forks source link

Add ability to create a compile_commands.json file #679

Open geo-ant opened 2 years ago

geo-ant commented 2 years ago

I would like to humbly request a feature to generate a compile_commands.json file from a project.yml using a new subcommand for ceedling. The compile_commands.json file is a file that basically lists the compile command for each translation unit in the project. The format of the JSON file is specified in the link that I provided. This has two important use cases:

  1. This can help debugging, although we are probably fine with the verbose options as they are.
  2. More importantly this will give us seamless vscode integration because the C/C++ plugin is able to parse the generated file and make IntelliSense understand the structure of the code. This means we get full code completion, navigation and such in a modern IDE with a huge market share. I would consider this a giant usability improvement.

What do you all think?

EDIT: I am willing to spend effort on this, although I don't have giant amounts of spare time. Unfortunately I don't speak Ruby, but I am willing to learn. Also I feel this should be a pretty low hanging fruit, because the compiler commands are very straightforward in the project.yml and we already have the ability to list all required sources as per ceedling files:source.

Letme commented 2 years ago

Add cscope/ctags generation then as well.

m4v commented 2 years ago

There's a plugin already, check if it works for you.

geo-ant commented 2 years ago

There's a plugin already, check if it works for you.

Thank you so much, this is exactly what I was looking for. I wish this was more prominently featured in a section like "IDE integration" in the main ceedling docs, because googling for that did not bring this plugin up (at least in my filter bubble). For anyone interested: the compile_commands.json file is generated in the artifacts directory inside of the ceedling build dir.

mvandervoord commented 2 years ago

I'm reopening this to remind us to add documentation for this feature.