colcon / colcon-cmake

Extension for colcon to support CMake packages
http://colcon.readthedocs.io
Apache License 2.0
16 stars 25 forks source link

Use `--cmake-concat-compile-commands` to concatenate multiple compile_commands.json files into a single file #62

Closed youtalk closed 4 years ago

youtalk commented 4 years ago

Resolved #61

This PR is a draft PR to resolve #61 issue. You can try it by the following command.

$ colcon build --cmake-concat-compile-commands --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
$ less build/compile_commands.json

It is very useful for me but I know it has no test and the process is not efficient. After making this PR, I've noticed that I need to implement a new colcon extension/package instead of modifying the colcon-cmake package.

galou commented 4 years ago

Did you manage to implement the said colcon extension? Where?

youtalk commented 4 years ago

Not yet... Are you interested in it?

galou commented 4 years ago

Yes, because I'm using YouCompleteMe and the setup would be very easy with a single compile_commands.json that I would symlink into my workspace directory. Without this extension, I'd have to symlink each compile_commands.json into the source directory of each package.

Is there any documentation how to develop an extension for colcon, so that I could maybe help you.

youtalk commented 4 years ago

I think there is no documentation yet but: https://colcon.readthedocs.io/en/released/developer/contribution.html#new-packages-extensions

dirk-thomas commented 4 years ago

Colcon simply uses Python enter points to register extensions (and even extension points).

The most common extension points are described in https://colcon.readthedocs.io/en/released/developer/extension-point.html. If you install colcon-devtools you can use the verbs extension-points and extensions to get complete lists.

The overall program flow of the relevant build command is visualized in https://colcon.readthedocs.io/en/released/developer/program-flow.html and might help to show the big picture.

Other than that there is always the code to browse or you can ask questions here.

galou commented 4 years ago

@dirk-thomas: thanks for offering help! My first question would be: how do I register an extension so that colcon finds it? Without installing anyting, I ran colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON --cmake-concat-compile-commands to see where Python was looking for extra modules but it looks that every unknown argument is treated as the name of a source directory.

dirk-thomas commented 4 years ago

My first question would be: how do I register an extension so that colcon finds it?

My previous comment described exactly that.

I would suggest to take a look at the sources of colcon-core to see an example how it contributes commands line arguments.