Skip to content

feat: add selective interface package inclusion#6

Open
esteve wants to merge 1 commit into
ros2-rust:mainfrom
esteve:feat/selective-interface-inclusion
Open

feat: add selective interface package inclusion#6
esteve wants to merge 1 commit into
ros2-rust:mainfrom
esteve:feat/selective-interface-inclusion

Conversation

@esteve

@esteve esteve commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

This PR allows downstream dependencies to select whether they want all the discovered craates with messages or only a predefined subset that rclrs requires. These changes are for supporting ros2-rust/ros2_rust#625

Signed-off-by: Esteve Fernandez <esteve@apache.org>
@esteve
esteve requested a review from maspe36 June 14, 2026 15:36
@esteve

esteve commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

@maspe36 let me know what you think of this, or if you think it's best to try a different approach. The relevant changes in rclrs are in https://github.com/ros2-rust/ros2_rust/pull/625/changes#diff-2f8219e965041e968786c959ba3d4469dcdc468c5f17502dffd2054e81a886a6R38 and https://github.com/ros2-rust/ros2_rust/pull/625/changes#diff-2f8219e965041e968786c959ba3d4469dcdc468c5f17502dffd2054e81a886a6R67 The default behavior in ros-env stays the same, only when using rclrs_core the set of dependencies is narrowed down to the minimum dependencies that rclrs needs for building without overlinking. I had to list each dependency separately in https://github.com/ros2-rust/ros-env/pull/6/changes#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542R28-R43 because features are static and I couldn't pass a variable list of crates/packages, but if there's a better way to do it without relying on features, happy to do it differently.

Comment thread README.md

Cargo feature selection is additive across the workspace: if any dependency enables a feature, it is unified for the final build.

For selective inclusion, disable default features and opt into the package features you need. `rclrs_core` is a feature alias for the common core interface set used by `rclrs` (`action_msgs`, `builtin_interfaces`, `rcl_interfaces`, `rosgraph_msgs`, and `unique_identifier_msgs`):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only concern with this approach is that users may think that they can selectively include any msg package, when in reality they can only include the ones defined in our feature set.

Perhaps we should lean on 2 features, include_all and manual (or some other name) and then if the later feature is selected we read a predefined metadata field and only include those deps?

ros-env = { 
  version = "0.2", 
  default-features = false, 
  features = ["manual"] 
}

# Okay, this is close in name to the other metadata we look for. 
# Maybe not `includes` but you get the point
[package.metadata.ros-env]
includes = [
  "action_msgs", 
  "builtin_interfaces", 
  "rcl_interfaces", 
  "my_msg"
]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, metadata approach won't work as downstream crates won't be able to read the metadata from consumer crates :/

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

Successfully merging this pull request may close these issues.

2 participants