| Crates.io | ros_msgs_include |
| lib.rs | ros_msgs_include |
| version | 0.1.1 |
| created_at | 2025-11-09 18:40:53.218592+00 |
| updated_at | 2025-11-09 18:45:52.163378+00 |
| description | Build script macro for including ROS 2 message types generated by rosidl_generator_rs via the AMENT_PREFIX_PATH |
| homepage | |
| repository | https://github.com/maspe36/ros_msgs_include |
| max_upload_size | |
| id | 1924362 |
| size | 10,915 |
include!() Generated SourcesThis approach works and seems to work well at that.
Essentially, we have a simple lib.rs which just includes a generated source file.
That generated source file, then include!()s all found .rs files in whatever directory
we find via the ament_prefix env var.
.msg, .srv, and/or .action files has been sourced by inspecting the AMENT_PREFIX env var.include!(<path>); in a generated source file, for each .rs file found.You should have a generated file, local to this crate, that looks like this
// env!("OUT_DIR") / shim.rs
pub mod msg_package {
include!("path/to/msg");
include!("path/to/action");
}
include!() this local generated source file and re-export any symbolsinclude!(concat!(env!("OUT_DIR"), "/shim.rs"));
pub use msg_package::*;
msg_package via the shim crate by specifying it in the Cargo.toml
Note, the version number would need to bump anytime there is a major update to the rosidl_runtime_rs crate or
changes to the deps of generated crates from rosidl_rust.[dependencies]
msg_package = "0.0.1"
env!()) automatically trigger a rebuild of the build.rs.
ament_cmake package), in a build.rs that invokes CMake
and then this macro.