Skip to content

Latest commit

 

History

History
20 lines (11 loc) · 1.44 KB

File metadata and controls

20 lines (11 loc) · 1.44 KB

colcon-ros-cargo

Build cargo projects with colcon.

Usage

Packages need to have a package.xml in addition to Cargo.toml. Make sure that you have built and loaded (source install/setup.bash) the extension.

Simply list dependencies (other ros.ament_cargo packages or message packages) in Cargo.toml and package.xml as if they were hosted on crates.io. colcon-ros-cargo will find the dependencies and create a .cargo/config.toml file that helps cargo find these packages.

Extra arguments to cargo can be passed via the --cargo-args option, e.g. colcon build --cargo-args --release.

After building, run binaries with ros2 run.

colcon-ros-cargo also aims to support using cargo directly as the primary build tool. Just build with colcon once, to make sure all non-Cargo dependencies are built and the .cargo/config.toml file exists, and then using cargo will just work – cargo build, cargo clippy, cargo doc, etc. When the dependency graph changes, rebuild with colcon.

Limitations

This is by far not a perfect build system.

Notably, there is quadratic build cost as a function of the dependency chain length. To illustrate this, assume there are packages A, B and C, where C depends on B and B depends on A. If colcon builds this workspace, it builds A first, then B, then C. However, Cargo will also build all the dependencies, i.e., to build B, Cargo will build A again, and to build C, it will build A and B again.