A tool to SYMbolically LINK Catkin Compile Commands.
Install rust, and make sure it is in your PATH by adding
bash
test -f "${HOME}/.cargo/env" && source "${HOME}/.cargo/env"
to your .bashrc
file (or equivalent).
Install this package using:
bash
cargo install --git https://github.com/MartinEekGerhardsen/symlinkccc.git
Then, in a catkin
workspace:
bash
catkin config --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
catkin build
symlinkccc
This command is pretty quick, especially compared to the average catkin
build time, so I made a wrapper for catkin
, which executes the symlinkccc
program after each catkin build
, while passing through any arguments. Add this to your .bashrc
file (or equivalent).
```bash catkinwrapper () { if (( $# == 0 )) then catkin else if [[ $1 == "build" ]] then catkin build ${@:2} && symlinkccc else catkin $@ fi fi }
alias catkin="catkinwrapper" ```
ROS is an extremely useful framework when working anywhere near the robotics field, and catkin
is an extremely useful set of tools for building and generally handling all the ROS packages. clangd
is a very nice language server for the C++ programming language. However, catkin
and clangd
are not really friends...
clangd
requires a compile_commands.json
-file in order to understand which dependencies a package has. This can be generated by the cmake
build tool, which catkin
calls under the hood. To make catkin
generate these files, add -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
to the cmake
arguments, e.g. like this:
bash
catkin config --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
The problem is that catkin places the compile_commands.json
-files in the build folder for each individual package, while clangd
wants it in the root of the source folder for each package (as it is slightly more likely that you'll edit code from the source folder compared to the build folder). An advantage of ROS/catkin
is that
cargo watch
can be used to check if something has to be re-linkedrospack
command implemented purely in rust