Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile only necessary packages to speed up compilation #53

Closed
jerry73204 opened this issue Jun 7, 2023 · 5 comments
Closed

Compile only necessary packages to speed up compilation #53

jerry73204 opened this issue Jun 7, 2023 · 5 comments

Comments

@jerry73204
Copy link
Contributor

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
Copy link
Collaborator

m-dahl commented Jun 7, 2023

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.

@jerry73204
Copy link
Contributor Author

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

@m-dahl
Copy link
Collaborator

m-dahl commented Jun 7, 2023

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++.

@jerry73204
Copy link
Contributor Author

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

@m-dahl
Copy link
Collaborator

m-dahl commented Jun 20, 2023

Added to readme as per your suggestion, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants