-
Notifications
You must be signed in to change notification settings - Fork 7
Relative Module Path Resolution #12
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,52 +25,28 @@ for subfolder, action in action_specs: | |
| action_srv_specs.append((subfolder, action.get_result_service)) | ||
| }@ | ||
|
|
||
| pub mod rmw { | ||
| #[cfg(feature = "serde")] | ||
| use serde::{Deserialize, Serialize}; | ||
| @{ | ||
| TEMPLATE( | ||
| 'msg_rmw.rs.em', | ||
| package_name=package_name, interface_path=interface_path, | ||
| msg_specs=action_msg_specs, | ||
| get_rs_name=get_rs_name, get_rmw_rs_type=get_rmw_rs_type, | ||
| pre_field_serde=pre_field_serde, | ||
| get_idiomatic_rs_type=get_idiomatic_rs_type, | ||
| constant_value_to_rs=constant_value_to_rs) | ||
|
|
||
| TEMPLATE( | ||
| 'srv_rmw.rs.em', | ||
| package_name=package_name, interface_path=interface_path, | ||
| srv_specs=action_srv_specs, | ||
| get_rs_name=get_rs_name, get_rmw_rs_type=get_rmw_rs_type, | ||
| pre_field_serde=pre_field_serde, | ||
| get_idiomatic_rs_type=get_idiomatic_rs_type, | ||
| constant_value_to_rs=constant_value_to_rs) | ||
| }@ | ||
| } // mod rmw | ||
|
|
||
| #[cfg(feature = "serde")] | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| @{ | ||
| TEMPLATE( | ||
| 'msg_idiomatic.rs.em', | ||
| 'templates/msg_idiomatic.rs.em', | ||
| package_name=package_name, interface_path=interface_path, | ||
| msg_specs=action_msg_specs, | ||
| get_rs_name=get_rs_name, get_rmw_rs_type=get_rmw_rs_type, | ||
| get_rs_name=get_rs_name, | ||
| get_rs_type=make_get_rs_type(True), | ||
| pre_field_serde=pre_field_serde, | ||
| get_idiomatic_rs_type=get_idiomatic_rs_type, | ||
| constant_value_to_rs=constant_value_to_rs) | ||
| }@ | ||
|
|
||
| @{ | ||
| TEMPLATE( | ||
| 'srv_idiomatic.rs.em', | ||
| 'templates/srv_idiomatic.rs.em', | ||
| package_name=package_name, interface_path=interface_path, | ||
| srv_specs=action_srv_specs, | ||
| get_rs_name=get_rs_name, get_rmw_rs_type=get_rmw_rs_type, | ||
| get_rs_name=get_rs_name, | ||
| get_rs_type=make_get_rs_type(True), | ||
| pre_field_serde=pre_field_serde, | ||
| get_idiomatic_rs_type=get_idiomatic_rs_type, | ||
| constant_value_to_rs=constant_value_to_rs) | ||
| }@ | ||
|
|
||
|
|
@@ -90,15 +66,15 @@ pub struct @(type_name); | |
|
|
||
| impl rosidl_runtime_rs::Action for @(type_name) { | ||
| // --- Associated types for client library users --- | ||
| type Goal = crate::@(subfolder)::@(type_name)@(ACTION_GOAL_SUFFIX); | ||
| type Result = crate::@(subfolder)::@(type_name)@(ACTION_RESULT_SUFFIX); | ||
| type Feedback = crate::@(subfolder)::@(type_name)@(ACTION_FEEDBACK_SUFFIX); | ||
| type Goal = @(type_name)@(ACTION_GOAL_SUFFIX); | ||
| type Result = @(type_name)@(ACTION_RESULT_SUFFIX); | ||
| type Feedback = @(type_name)@(ACTION_FEEDBACK_SUFFIX); | ||
|
|
||
| // --- Associated types for client library implementation --- | ||
| type FeedbackMessage = crate::@(subfolder)::rmw::@(type_name)@(ACTION_FEEDBACK_MESSAGE_SUFFIX); | ||
| type SendGoalService = crate::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SERVICE_SUFFIX); | ||
| type FeedbackMessage = super::@(subfolder)::@(type_name)@(ACTION_FEEDBACK_MESSAGE_SUFFIX); | ||
| type SendGoalService = super::@(subfolder)::@(type_name)@(ACTION_GOAL_SERVICE_SUFFIX); | ||
| type CancelGoalService = action_msgs::srv::rmw::CancelGoal; | ||
| type GetResultService = crate::@(subfolder)::rmw::@(type_name)@(ACTION_RESULT_SERVICE_SUFFIX); | ||
| type GetResultService = super::@(subfolder)::@(type_name)@(ACTION_RESULT_SERVICE_SUFFIX); | ||
|
Comment on lines
+74
to
+77
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A lot of the changes look like this, simply replacing |
||
|
|
||
| // --- Methods for client library implementation --- | ||
| fn get_type_support() -> *const std::ffi::c_void { | ||
|
|
@@ -108,28 +84,28 @@ impl rosidl_runtime_rs::Action for @(type_name) { | |
|
|
||
| fn create_goal_request( | ||
| goal_id: &[u8; 16], | ||
| goal: crate::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SUFFIX), | ||
| ) -> crate::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SERVICE_SUFFIX)@(SERVICE_REQUEST_MESSAGE_SUFFIX) { | ||
| crate::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SERVICE_SUFFIX)@(SERVICE_REQUEST_MESSAGE_SUFFIX) { | ||
| goal: super::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SUFFIX), | ||
| ) -> super::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SERVICE_SUFFIX)@(SERVICE_REQUEST_MESSAGE_SUFFIX) { | ||
| super::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SERVICE_SUFFIX)@(SERVICE_REQUEST_MESSAGE_SUFFIX) { | ||
| goal_id: unique_identifier_msgs::msg::rmw::UUID { uuid: *goal_id }, | ||
| goal, | ||
| } | ||
| } | ||
|
|
||
| fn split_goal_request( | ||
| request: crate::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SERVICE_SUFFIX)@(SERVICE_REQUEST_MESSAGE_SUFFIX), | ||
| request: super::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SERVICE_SUFFIX)@(SERVICE_REQUEST_MESSAGE_SUFFIX), | ||
| ) -> ( | ||
| [u8; 16], | ||
| crate::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SUFFIX), | ||
| super::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SUFFIX), | ||
| ) { | ||
| (request.goal_id.uuid, request.goal) | ||
| } | ||
|
|
||
| fn create_goal_response( | ||
| accepted: bool, | ||
| stamp: (i32, u32), | ||
| ) -> crate::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SERVICE_SUFFIX)@(SERVICE_RESPONSE_MESSAGE_SUFFIX) { | ||
| crate::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SERVICE_SUFFIX)@(SERVICE_RESPONSE_MESSAGE_SUFFIX) { | ||
| ) -> super::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SERVICE_SUFFIX)@(SERVICE_RESPONSE_MESSAGE_SUFFIX) { | ||
| super::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SERVICE_SUFFIX)@(SERVICE_RESPONSE_MESSAGE_SUFFIX) { | ||
| accepted, | ||
| stamp: builtin_interfaces::msg::rmw::Time { | ||
| sec: stamp.0, | ||
|
|
@@ -139,65 +115,65 @@ impl rosidl_runtime_rs::Action for @(type_name) { | |
| } | ||
|
|
||
| fn get_goal_response_accepted( | ||
| response: &crate::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SERVICE_SUFFIX)@(SERVICE_RESPONSE_MESSAGE_SUFFIX), | ||
| response: &super::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SERVICE_SUFFIX)@(SERVICE_RESPONSE_MESSAGE_SUFFIX), | ||
| ) -> bool { | ||
| response.accepted | ||
| } | ||
|
|
||
| fn get_goal_response_stamp( | ||
| response: &crate::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SERVICE_SUFFIX)@(SERVICE_RESPONSE_MESSAGE_SUFFIX), | ||
| response: &super::@(subfolder)::rmw::@(type_name)@(ACTION_GOAL_SERVICE_SUFFIX)@(SERVICE_RESPONSE_MESSAGE_SUFFIX), | ||
| ) -> (i32, u32) { | ||
| (response.stamp.sec, response.stamp.nanosec) | ||
| } | ||
|
|
||
| fn create_feedback_message( | ||
| goal_id: &[u8; 16], | ||
| feedback: crate::@(subfolder)::rmw::@(type_name)@(ACTION_FEEDBACK_SUFFIX), | ||
| ) -> crate::@(subfolder)::rmw::@(type_name)@(ACTION_FEEDBACK_MESSAGE_SUFFIX) { | ||
| let mut message = crate::@(subfolder)::rmw::@(type_name)@(ACTION_FEEDBACK_MESSAGE_SUFFIX)::default(); | ||
| feedback: super::@(subfolder)::rmw::@(type_name)@(ACTION_FEEDBACK_SUFFIX), | ||
| ) -> super::@(subfolder)::rmw::@(type_name)@(ACTION_FEEDBACK_MESSAGE_SUFFIX) { | ||
| let mut message = super::@(subfolder)::rmw::@(type_name)@(ACTION_FEEDBACK_MESSAGE_SUFFIX)::default(); | ||
| message.goal_id.uuid = *goal_id; | ||
| message.feedback = feedback; | ||
| message | ||
| } | ||
|
|
||
| fn split_feedback_message( | ||
| feedback: crate::@(subfolder)::rmw::@(type_name)@(ACTION_FEEDBACK_MESSAGE_SUFFIX), | ||
| feedback: super::@(subfolder)::rmw::@(type_name)@(ACTION_FEEDBACK_MESSAGE_SUFFIX), | ||
| ) -> ( | ||
| [u8; 16], | ||
| crate::@(subfolder)::rmw::@(type_name)@(ACTION_FEEDBACK_SUFFIX), | ||
| super::@(subfolder)::rmw::@(type_name)@(ACTION_FEEDBACK_SUFFIX), | ||
| ) { | ||
| (feedback.goal_id.uuid, feedback.feedback) | ||
| } | ||
|
|
||
| fn create_result_request( | ||
| goal_id: &[u8; 16], | ||
| ) -> crate::@(subfolder)::rmw::@(type_name)@(ACTION_RESULT_SERVICE_SUFFIX)@(SERVICE_REQUEST_MESSAGE_SUFFIX) { | ||
| crate::@(subfolder)::rmw::@(type_name)@(ACTION_RESULT_SERVICE_SUFFIX)@(SERVICE_REQUEST_MESSAGE_SUFFIX) { | ||
| ) -> super::@(subfolder)::rmw::@(type_name)@(ACTION_RESULT_SERVICE_SUFFIX)@(SERVICE_REQUEST_MESSAGE_SUFFIX) { | ||
| super::@(subfolder)::rmw::@(type_name)@(ACTION_RESULT_SERVICE_SUFFIX)@(SERVICE_REQUEST_MESSAGE_SUFFIX) { | ||
| goal_id: unique_identifier_msgs::msg::rmw::UUID { uuid: *goal_id }, | ||
| } | ||
| } | ||
|
|
||
| fn get_result_request_uuid( | ||
| request: &crate::@(subfolder)::rmw::@(type_name)@(ACTION_RESULT_SERVICE_SUFFIX)@(SERVICE_REQUEST_MESSAGE_SUFFIX), | ||
| request: &super::@(subfolder)::rmw::@(type_name)@(ACTION_RESULT_SERVICE_SUFFIX)@(SERVICE_REQUEST_MESSAGE_SUFFIX), | ||
| ) -> &[u8; 16] { | ||
| &request.goal_id.uuid | ||
| } | ||
|
|
||
| fn create_result_response( | ||
| status: i8, | ||
| result: crate::@(subfolder)::rmw::@(type_name)@(ACTION_RESULT_SUFFIX), | ||
| ) -> crate::@(subfolder)::rmw::@(type_name)@(ACTION_RESULT_SERVICE_SUFFIX)@(SERVICE_RESPONSE_MESSAGE_SUFFIX) { | ||
| crate::@(subfolder)::rmw::@(type_name)@(ACTION_RESULT_SERVICE_SUFFIX)@(SERVICE_RESPONSE_MESSAGE_SUFFIX) { | ||
| result: super::@(subfolder)::rmw::@(type_name)@(ACTION_RESULT_SUFFIX), | ||
| ) -> super::@(subfolder)::rmw::@(type_name)@(ACTION_RESULT_SERVICE_SUFFIX)@(SERVICE_RESPONSE_MESSAGE_SUFFIX) { | ||
| super::@(subfolder)::rmw::@(type_name)@(ACTION_RESULT_SERVICE_SUFFIX)@(SERVICE_RESPONSE_MESSAGE_SUFFIX) { | ||
| status, | ||
| result, | ||
| } | ||
| } | ||
|
|
||
| fn split_result_response( | ||
| response: crate::@(subfolder)::rmw::@(type_name)@(ACTION_RESULT_SERVICE_SUFFIX)@(SERVICE_RESPONSE_MESSAGE_SUFFIX) | ||
| response: super::@(subfolder)::rmw::@(type_name)@(ACTION_RESULT_SERVICE_SUFFIX)@(SERVICE_RESPONSE_MESSAGE_SUFFIX) | ||
| ) -> ( | ||
| i8, | ||
| crate::@(subfolder)::rmw::@(type_name)@(ACTION_RESULT_SUFFIX), | ||
| super::@(subfolder)::rmw::@(type_name)@(ACTION_RESULT_SUFFIX), | ||
| ) { | ||
| (response.status, response.result) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| @{ | ||
| from rosidl_parser.definition import ( | ||
| ACTION_FEEDBACK_MESSAGE_SUFFIX, | ||
| ACTION_FEEDBACK_SUFFIX, | ||
| ACTION_GOAL_SERVICE_SUFFIX, | ||
| ACTION_GOAL_SUFFIX, | ||
| ACTION_RESULT_SERVICE_SUFFIX, | ||
| ACTION_RESULT_SUFFIX, | ||
| SERVICE_REQUEST_MESSAGE_SUFFIX, | ||
| SERVICE_RESPONSE_MESSAGE_SUFFIX, | ||
| ) | ||
|
|
||
| action_msg_specs = [] | ||
|
|
||
| for subfolder, action in action_specs: | ||
| action_msg_specs.append((subfolder, action.goal)) | ||
| action_msg_specs.append((subfolder, action.result)) | ||
| action_msg_specs.append((subfolder, action.feedback)) | ||
| action_msg_specs.append((subfolder, action.feedback_message)) | ||
|
|
||
| action_srv_specs = [] | ||
|
|
||
| for subfolder, action in action_specs: | ||
| action_srv_specs.append((subfolder, action.send_goal_service)) | ||
| action_srv_specs.append((subfolder, action.get_result_service)) | ||
| }@ | ||
|
|
||
| #[cfg(feature = "serde")] | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| @{ | ||
| TEMPLATE( | ||
| '../templates/msg_rmw.rs.em', | ||
| package_name=package_name, interface_path=interface_path, | ||
| msg_specs=action_msg_specs, | ||
| get_rs_name=get_rs_name, | ||
| get_rs_type=make_get_rs_type(False), | ||
| pre_field_serde=pre_field_serde, | ||
| constant_value_to_rs=constant_value_to_rs) | ||
|
|
||
| TEMPLATE( | ||
| '../templates/srv_rmw.rs.em', | ||
| package_name=package_name, interface_path=interface_path, | ||
| srv_specs=action_srv_specs, | ||
| get_rs_name=get_rs_name, | ||
| get_rs_type=make_get_rs_type(False), | ||
| pre_field_serde=pre_field_serde, | ||
| constant_value_to_rs=constant_value_to_rs) | ||
| }@ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| use std::path::Path; | ||
| // use std::path::Path; | ||
|
|
||
| fn main() { | ||
| let lib_dir = Path::new("../../../lib") | ||
| .canonicalize() | ||
| .expect("Could not find '../../../lib'"); | ||
| // This allows building Rust packages that depend on message crates without | ||
| // sourcing the install directory first. | ||
| println!("cargo:rustc-link-search={}", lib_dir.display()); | ||
| // let lib_dir = Path::new("../../../lib") | ||
| // .canonicalize() | ||
| // .expect("Could not find '../../../lib'"); | ||
| // // This allows building Rust packages that depend on message crates without | ||
| // // sourcing the install directory first. | ||
| // println!("cargo:rustc-link-search={}", lib_dir.display()); | ||
| } |
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still ultimately want this structure, but a crate that wishes to re-export any of these symbols will need to arbitrarily add private pub mod builtin_interfaces { ... };
pub mod std_msgs {
pub mod msg {
use crate::builtin_interfaces;
include!("path/to/generated/code");
pub mod rmw {
use crate::builtin_interfaces;
include!("path/to/generated/rmw/code");
}
}
}We need to create this rmw module in the generated crates lib.rs file rather than within these generated |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,13 @@ | ||
| pub mod rmw { | ||
| #[cfg(feature = "serde")] | ||
| use serde::{Deserialize, Serialize}; | ||
| @{ | ||
| TEMPLATE( | ||
| 'msg_rmw.rs.em', | ||
| package_name=package_name, interface_path=interface_path, | ||
| msg_specs=msg_specs, | ||
| get_rs_name=get_rs_name, get_rmw_rs_type=get_rmw_rs_type, | ||
| pre_field_serde=pre_field_serde, | ||
| get_idiomatic_rs_type=get_idiomatic_rs_type, | ||
| constant_value_to_rs=constant_value_to_rs) | ||
| }@ | ||
| } // mod rmw | ||
|
|
||
| #[cfg(feature = "serde")] | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| @{ | ||
| TEMPLATE( | ||
| 'msg_idiomatic.rs.em', | ||
| 'templates/msg_idiomatic.rs.em', | ||
| package_name=package_name, interface_path=interface_path, | ||
| msg_specs=msg_specs, | ||
| get_rs_name=get_rs_name, get_rmw_rs_type=get_rmw_rs_type, | ||
| get_rs_name=get_rs_name, | ||
| get_rs_type=make_get_rs_type(True), | ||
| pre_field_serde=pre_field_serde, | ||
| get_idiomatic_rs_type=get_idiomatic_rs_type, | ||
| constant_value_to_rs=constant_value_to_rs) | ||
| }@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The additional metadata I am exporting.