sequenceplanner/r2r

Compile only necessary packages to speed up compilation

jerry73204 opened this issue · 5 comments

Currently, r2r compiles all discovered message types, which leads to a lengthy compilation time.
The idea is to let r2r acknowledge required ROS packages in package.xml (or Cargo.toml), and compile necessary packages.
The tricky part is to allow r2r to learn requested packages from dependent crates. It is usually done by feature flags or environment variables. A relevant discussion can be found here rust-lang/cargo#4121.

m-dahl commented

Hi.

We have this though I realize it is not well documented. You can see a note about it under "building with cargo" here.

It is just a crude filter so it does not know about dependencies, so if you have nested message types you need to explicitly include all of the packages you use.

If you use the colcon way of building it will also only build the requested packages. I hope this helps.

How does r2r discover requested packages when using colcon? Just curious.

m-dahl commented

Sorry that made it sound like getting the requested packages is automatic, it is not. If you check the r2r_minimal_node package that I linked you will see the following in the cmakelists file.

# put ros package dependencies here.
r2r_cargo(std_msgs               # just to test that it works
          rcl                    # we need the c ros2 api
          rcl_action             # as of r2r 0.1.0, we also need the action api
          r2r_minimal_node_msgs  # our custom message types
         )

Then the r2r_cargo function populates some environment variables in a similar way as the filter.

One improvement would of course be to get the needed packages from package.xml instead of doing it manually. But I think this works well enough, and iirc you also have to include the cmake dependencies manually when using c++.

Thanks for your explanation. This feature should be well documented in README. It helps reducing lots of compilation time.

m-dahl commented

Added to readme as per your suggestion, thanks.