Skip to content

feat: obtain interface version from cmake variable #191

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

Merged
merged 2 commits into from
Jun 7, 2022

Conversation

wep21
Copy link
Contributor

@wep21 wep21 commented Jun 5, 2022

Closes #116

@esteve esteve self-requested a review June 5, 2022 16:34
@@ -119,6 +119,7 @@ foreach(dep ${target_dependencies})
endforeach()

set(generator_arguments_file "${CMAKE_CURRENT_BINARY_DIR}/rosidl_generator_rs__arguments.json")
set(package_version "${${PROJECT_NAME}_VERSION}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of using a separate variable for storing the package version, you can reuse the arguments file and write the value of ${${PROJECT_NAME}_VERSION} there.

Copy link
Contributor Author

@wep21 wep21 Jun 5, 2022

Choose a reason for hiding this comment

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

I appended a package version into a generator argument file in 0c78e27.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sample json

{
  "package_name": "action_msgs",
  "output_dir": "/home/daisuke/workspace/ros2_rust_ws/build/action_msgs/rosidl_generator_rs/action_msgs",
  "template_dir": "/home/daisuke/workspace/ros2_rust_ws/install/rosidl_generator_rs/share/rosidl_generator_rs/cmake/../resource",
  "idl_tuples": [
    "/home/daisuke/workspace/ros2_rust_ws/build/action_msgs/rosidl_adapter/action_msgs:msg/GoalInfo.idl",
    "/home/daisuke/workspace/ros2_rust_ws/build/action_msgs/rosidl_adapter/action_msgs:msg/GoalStatus.idl",
    "/home/daisuke/workspace/ros2_rust_ws/build/action_msgs/rosidl_adapter/action_msgs:msg/GoalStatusArray.idl",
    "/home/daisuke/workspace/ros2_rust_ws/build/action_msgs/rosidl_adapter/action_msgs:srv/CancelGoal.idl"
  ],
  "ros_interface_files": [
    "/home/daisuke/workspace/ros2_rust_ws/build/action_msgs/rosidl_adapter/action_msgs/msg/GoalInfo.idl",
    "/home/daisuke/workspace/ros2_rust_ws/build/action_msgs/rosidl_adapter/action_msgs/msg/GoalStatus.idl",
    "/home/daisuke/workspace/ros2_rust_ws/build/action_msgs/rosidl_adapter/action_msgs/msg/GoalStatusArray.idl",
    "/home/daisuke/workspace/ros2_rust_ws/build/action_msgs/rosidl_adapter/action_msgs/srv/CancelGoal.idl"
  ],
  "ros_interface_dependencies": [
    "builtin_interfaces:/home/daisuke/workspace/ros2_rust_ws/install/builtin_interfaces/share/builtin_interfaces/msg/Duration.idl",
    "builtin_interfaces:/home/daisuke/workspace/ros2_rust_ws/install/builtin_interfaces/share/builtin_interfaces/msg/Time.idl",
    "unique_identifier_msgs:/opt/ros/humble/share/unique_identifier_msgs/msg/UUID.idl"
  ],
  "target_dependencies": [
    "/home/daisuke/workspace/ros2_rust_ws/install/rosidl_generator_rs/share/rosidl_generator_rs/cmake/../../../lib/rosidl_generator_rs/rosidl_generator_rs",
    "/home/daisuke/workspace/ros2_rust_ws/install/rosidl_generator_rs/share/rosidl_generator_rs/cmake/../../../local/lib/python3.10/dist-packages/rosidl_generator_rs/__init__.py",
    "/home/daisuke/workspace/ros2_rust_ws/install/rosidl_generator_rs/share/rosidl_generator_rs/cmake/../resource/msg.rs.em",
    "/home/daisuke/workspace/ros2_rust_ws/install/rosidl_generator_rs/share/rosidl_generator_rs/cmake/../resource/srv.rs.em",
    "/home/daisuke/workspace/ros2_rust_ws/build/action_msgs/rosidl_adapter/action_msgs/msg/GoalInfo.idl",
    "/home/daisuke/workspace/ros2_rust_ws/build/action_msgs/rosidl_adapter/action_msgs/msg/GoalStatus.idl",
    "/home/daisuke/workspace/ros2_rust_ws/build/action_msgs/rosidl_adapter/action_msgs/msg/GoalStatusArray.idl",
    "/home/daisuke/workspace/ros2_rust_ws/build/action_msgs/rosidl_adapter/action_msgs/srv/CancelGoal.idl",
    "/home/daisuke/workspace/ros2_rust_ws/build/action_msgs/rosidl_adapter/action_msgs/msg/GoalInfo.idl",
    "/home/daisuke/workspace/ros2_rust_ws/build/action_msgs/rosidl_adapter/action_msgs/msg/GoalStatus.idl",
    "/home/daisuke/workspace/ros2_rust_ws/build/action_msgs/rosidl_adapter/action_msgs/msg/GoalStatusArray.idl",
    "/home/daisuke/workspace/ros2_rust_ws/build/action_msgs/rosidl_adapter/action_msgs/srv/CancelGoal.idl",
    "/home/daisuke/workspace/ros2_rust_ws/install/builtin_interfaces/share/builtin_interfaces/msg/Duration.idl",
    "/home/daisuke/workspace/ros2_rust_ws/install/builtin_interfaces/share/builtin_interfaces/msg/Time.idl",
    "/opt/ros/humble/share/unique_identifier_msgs/msg/UUID.idl"
  ],
  "package_version": "1.2.0"
}

@esteve
Copy link
Collaborator

esteve commented Jun 5, 2022

@wep21 thanks! My only feedback is about how to pass the package version down to the generator, but apart from that, the PR looks good to me 🙂

@wep21 wep21 requested a review from esteve June 5, 2022 17:57
@@ -130,6 +130,11 @@ rosidl_write_generator_arguments(
TARGET_DEPENDENCIES ${target_dependencies}
)

file(READ ${generator_arguments_file} contents)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, I just realized that rosidl_write_generator_arguments can't pass the package version, I'll file a ticket in the rosidl repo, but for now this code is fine. Thanks!

@esteve
Copy link
Collaborator

esteve commented Jun 7, 2022

@wep21 thanks!

@esteve esteve merged commit 1abc390 into ros2-rust:master Jun 7, 2022
@wep21 wep21 deleted the feature/interface-version branch June 7, 2022 08:37
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.

Use version number from package.xml in the generation of messages
2 participants