Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
29b44b7
Initial implementation
esteve Feb 2, 2018
cae8d54
Crystal and more (#3)
lelongg May 5, 2019
515b1dc
Build on Dashing+ (#24)
nnarain Aug 24, 2020
6d8826b
Fix array type generation. And append an '_' to field names that an r…
nnarain Nov 11, 2020
0e94f69
Build system refactor (#64)
jhdcs Nov 22, 2021
34b005d
Use the ament_cargo build type (#73)
nnmm Feb 18, 2022
c5738a6
Message generation refactoring (#80)
nnmm Mar 18, 2022
dc37b06
Enable Clippy in CI (#83)
nnmm Mar 21, 2022
4e0632e
Bump every package to version 0.2 (#100)
nnmm Apr 17, 2022
382873b
Add serde support to messages (#131)
nnmm Apr 29, 2022
e661367
Generate Cargo.toml of message crate with an EmPy template, not CMake…
nnmm May 2, 2022
42b81ff
Add build.rs to messages to automatically find the message libraries …
nnmm May 10, 2022
ac8793e
feat: obtain interface version from cmake variable (#191)
wep21 Jun 7, 2022
1867740
Added support for clients and services (#146)
esteve Jul 8, 2022
850fa48
Fix path handling in rosidl_generator_rs on Windows (#228)
nnmm Jul 15, 2022
8a87cac
Small bugfix for sequences of WStrings (#240)
nnmm Jul 31, 2022
7f5faa9
Add support for constants to message generation (#269)
nnmm Sep 30, 2022
b0128c4
Bump package versions to 0.3 (#274)
nnmm Oct 3, 2022
df75c19
Add TYPE_NAME constant to messages and make error fields public (#277)
nnmm Oct 5, 2022
58d8523
Version 0.3.1 (#285)
nnmm Oct 17, 2022
0db3a63
Remove libc dependencies (#284)
Tacha-S Oct 18, 2022
fdc19d3
Swapped usage of rosidl_cmake over to the new rosidl_pycommon. (#297)
maspe36 Apr 6, 2023
96322cd
add serde big array support (fixed #327) (#328)
fawdlstty Aug 22, 2023
76dde39
Version 0.4.0 (#343)
esteve Nov 7, 2023
227a6ff
Revert "Version 0.4.0 (#343)" (#344)
esteve Nov 7, 2023
90f3ab9
Version 0.4.0 (#346)
esteve Nov 7, 2023
7f888ff
Version 0.4.1 (#353)
esteve Nov 28, 2023
b122fea
Add wchar support (#349)
maspe36 Jan 9, 2024
40e6971
Allow ros2_rust to be built within a distro workspace
mxgrey Mar 12, 2024
c6dba8f
Declare rust_packages only when installing Rust IDL bindings (#380)
mxgrey Mar 20, 2024
f59d00d
Action message support (#417)
nwn Oct 26, 2024
0c683f5
Update vendored interface packages (#423)
nwn Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Message generation refactoring (#80)
Previously, only messages consisting of basic types and strings were supported. Now, all message types will work, including those that have fields of nested types, bounded types, or arrays.

Changes:
- The "rsext" library is deleted
- Unused messages in "rosidl_generator_rs" are deleted
- There is a new package, "rosidl_runtime_rs", see below
- The RMW-compatible messages from C, which do not require an extra conversion step, are exposed in addition to the "idiomatic" messages
- Publisher and subscription are changed to work with both idiomatic and rmw types, through the unifying `Message` trait

On `rosidl_runtime_rs`: This package is the successor of `rclrs_msg_utilities` package, but doesn't have much in common with it anymore.
It provides common types and functionality for messages. The `String` and `Sequence` types and their variants in that package essentially wrap C types from the `rosidl_runtime_c` package and C messages generated by the "rosidl_generator_c" package.
A number of functions and traits are implemented on these types, so that they feel as ergonomic as possible, for instance, a `seq!` macro for creating a sequence. There is also some documentation and doctests.

The memory for the (non-pretty) message types is managed by the C allocator.

Not yet implemented:
- long double
- constants
- Services/clients
- @verbatim comments
- ndarray for sequences/arrays of numeric types
- implementing `Eq`, `Ord` and `Hash` when a message contains no floats
  • Loading branch information
nnmm committed Mar 18, 2022
commit c5738a65457d033719459a1e5fedf8e7e01a9bee
111 changes: 11 additions & 100 deletions rosidl_generator_rs/cmake/rosidl_generator_rs_generate_interfaces.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,8 @@ set(_output_path
set(_generated_extension_files "")
set(_generated_common_rs_files "")

set(_generated_c_files "")
set(_generated_rs_files "")

set(_generated_msg_rs_files "")
set(_generated_msg_c_files "")
set(_generated_srv_rs_files "")
set(_generated_srv_c_files "")

set(_has_msg FALSE)
set(_has_srv FALSE)
Expand Down Expand Up @@ -110,8 +105,6 @@ endforeach()
set(target_dependencies
"${rosidl_generator_rs_BIN}"
${rosidl_generator_rs_GENERATOR_FILES}
"${rosidl_generator_rs_TEMPLATE_DIR}/msg.c.em"
"${rosidl_generator_rs_TEMPLATE_DIR}/srv.c.em"
"${rosidl_generator_rs_TEMPLATE_DIR}/msg.rs.em"
"${rosidl_generator_rs_TEMPLATE_DIR}/srv.rs.em"
${rosidl_generate_interfaces_ABS_IDL_FILES}
Expand Down Expand Up @@ -139,7 +132,7 @@ file(MAKE_DIRECTORY "${_output_path}")

set(_target_suffix "__rs")

set(CRATES_DEPENDENCIES "rclrs_msg_utilities = \"*\"")
set(CRATES_DEPENDENCIES "rosidl_runtime_rs = \"*\"")
foreach(_pkg_name ${rosidl_generate_interfaces_DEPENDENCY_PACKAGE_NAMES})
find_package(${_pkg_name} REQUIRED)
set(CRATES_DEPENDENCIES "${CRATES_DEPENDENCIES}\n${_pkg_name} = \"*\"")
Expand All @@ -162,117 +155,35 @@ set_property(
${_generated_extension_files}
${_generated_common_rs_files}
${_generated_msg_rs_files}
${_generated_msg_c_files}
${_generated_srv_rs_files}
PROPERTY GENERATED 1)

set(_type_support_by_generated_c_files ${_type_support_by_generated_msg_c_files} ${_type_support_by_generated_srv_c_files})
set(_generated_rs_files ${_generated_msg_rs_files} ${_generated_srv_rs_files})

set(_rsext_suffix "__rsext")
foreach(_typesupport_impl ${_typesupport_impls})
find_package(${_typesupport_impl} REQUIRED)

set(_extension_compile_flags "")
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(_extension_compile_flags -Wall -Wextra)
endif()

set(_target_name "${PROJECT_NAME}__${_typesupport_impl}${_rsext_suffix}")

add_library(${_target_name} SHARED
${_generated_extension_${_typesupport_impl}_files}
)
add_dependencies(
${_target_name}
${rosidl_generate_interfaces_TARGET}${_target_suffix}
${rosidl_generate_interfaces_TARGET}__rosidl_typesupport_c
)

target_link_libraries(
${_target_name}
${PROJECT_NAME}__${_typesupport_impl}
${rosidl_generate_interfaces_TARGET}__rosidl_generator_c
)

if (NOT $ENV{ROS_DISTRO} STREQUAL "rolling")
rosidl_target_interfaces(${_target_name}
${rosidl_generate_interfaces_TARGET} rosidl_typesupport_c)
else()
rosidl_get_typesupport_target(rust_typesupport_target ${rosidl_generate_interfaces_TARGET} rosidl_typesupport_c)
target_link_libraries(${_target_name} ${rust_typesupport_target})
endif()

target_include_directories(${_target_name}
PUBLIC
${CMAKE_CURRENT_BINARY_DIR}/rosidl_generator_c
${CMAKE_CURRENT_BINARY_DIR}/rosidl_generator_rs
)

ament_target_dependencies(${_target_name}
"rosidl_runtime_c"
"rosidl_typesupport_c"
"rosidl_typesupport_interface"
)
foreach(_pkg_name ${rosidl_generate_interfaces_DEPENDENCY_PACKAGE_NAMES})
ament_target_dependencies(${_target_name}
${_pkg_name}
)
endforeach()

add_dependencies(${_target_name}
${rosidl_generate_interfaces_TARGET}__${_typesupport_impl}
)
ament_target_dependencies(${_target_name}
"rosidl_runtime_c"
"rosidl_generator_rs"
)

if(NOT rosidl_generate_interfaces_SKIP_INSTALL)
install(
DIRECTORY "${_output_path}/rust"
DESTINATION "share/${PROJECT_NAME}"
)
install(TARGETS ${_target_name}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)

configure_file("${rosidl_generator_rs_TEMPLATE_DIR}/Cargo.toml.in"
"share/${PROJECT_NAME}/rust/Cargo.toml"
@ONLY)

install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/rust/Cargo.toml"
DESTINATION share/${PROJECT_NAME}/rust/
)
endif()
endforeach()

configure_file("${rosidl_generator_rs_TEMPLATE_DIR}/Cargo.toml.in"
"share/${PROJECT_NAME}/rust/Cargo.toml"
@ONLY)

install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/rust/Cargo.toml"
DESTINATION share/${PROJECT_NAME}/rust/
)

if(BUILD_TESTING AND rosidl_generate_interfaces_ADD_LINTER_TESTS)
if(
NOT _generated_msg_rs_files STREQUAL "" OR
NOT _generated_srv_rs_files STREQUAL ""
)
find_package(ament_cmake_cppcheck REQUIRED)
ament_cppcheck(
TESTNAME "cppcheck_rosidl_generated_rs"
"${_output_path}")

find_package(ament_cmake_cpplint REQUIRED)
get_filename_component(_cpplint_root "${_output_path}" DIRECTORY)
ament_cpplint(
TESTNAME "cpplint_rosidl_generated_rs"
# the generated code might contain longer lines for templated types
MAX_LINE_LENGTH 999
ROOT "${_cpplint_root}"
"${_output_path}")

find_package(ament_cmake_uncrustify REQUIRED)
ament_uncrustify(
TESTNAME "uncrustify_rosidl_generated_rs"
# the generated code might contain longer lines for templated types
MAX_LINE_LENGTH 999
"${_output_path}")
# TODO(esteve): add linters for Rust files
endif()
endif()
1 change: 0 additions & 1 deletion rosidl_generator_rs/msg/Bool.msg

This file was deleted.

1 change: 0 additions & 1 deletion rosidl_generator_rs/msg/Byte.msg

This file was deleted.

1 change: 0 additions & 1 deletion rosidl_generator_rs/msg/Char.msg

This file was deleted.

5 changes: 0 additions & 5 deletions rosidl_generator_rs/msg/Constants.msg

This file was deleted.

1 change: 0 additions & 1 deletion rosidl_generator_rs/msg/Empty.msg

This file was deleted.

1 change: 0 additions & 1 deletion rosidl_generator_rs/msg/Float32.msg

This file was deleted.

1 change: 0 additions & 1 deletion rosidl_generator_rs/msg/Float64.msg

This file was deleted.

1 change: 0 additions & 1 deletion rosidl_generator_rs/msg/Int16.msg

This file was deleted.

1 change: 0 additions & 1 deletion rosidl_generator_rs/msg/Int32.msg

This file was deleted.

1 change: 0 additions & 1 deletion rosidl_generator_rs/msg/Int64.msg

This file was deleted.

1 change: 0 additions & 1 deletion rosidl_generator_rs/msg/Int8.msg

This file was deleted.

6 changes: 0 additions & 6 deletions rosidl_generator_rs/msg/Nested.msg

This file was deleted.

18 changes: 0 additions & 18 deletions rosidl_generator_rs/msg/Primitives.msg

This file was deleted.

4 changes: 0 additions & 4 deletions rosidl_generator_rs/msg/Strings.msg

This file was deleted.

1 change: 0 additions & 1 deletion rosidl_generator_rs/msg/Uint16.msg

This file was deleted.

1 change: 0 additions & 1 deletion rosidl_generator_rs/msg/Uint32.msg

This file was deleted.

1 change: 0 additions & 1 deletion rosidl_generator_rs/msg/Uint64.msg

This file was deleted.

1 change: 0 additions & 1 deletion rosidl_generator_rs/msg/Uint8.msg

This file was deleted.

23 changes: 0 additions & 23 deletions rosidl_generator_rs/msg/Various.msg

This file was deleted.

4 changes: 2 additions & 2 deletions rosidl_generator_rs/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

<buildtool_depend>ament_cmake</buildtool_depend>

<buildtool_depend>rclrs_msg_utilities</buildtool_depend>
<buildtool_depend>rosidl_runtime_rs</buildtool_depend>

<buildtool_export_depend>ament_cmake</buildtool_export_depend>
<buildtool_export_depend>rosidl_cmake</buildtool_export_depend>
<buildtool_export_depend>rclrs_msg_utilities</buildtool_export_depend>
<buildtool_export_depend>rosidl_runtime_rs</buildtool_export_depend>
<buildtool_export_depend>rosidl_typesupport_c</buildtool_export_depend>
<buildtool_export_depend>rosidl_typesupport_interface</buildtool_export_depend>

Expand Down
2 changes: 1 addition & 1 deletion rosidl_generator_rs/resource/Cargo.toml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "@PROJECT_NAME@"
version = "0.1.0"
edition = "2018"
edition = "2021"

[dependencies]
libc = "0.2"
Expand Down
5 changes: 1 addition & 4 deletions rosidl_generator_rs/resource/lib.rs.em
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
extern crate rclrs_msg_utilities;
extern crate libc;

@[if len(msg_specs) > 0]@
pub mod msg;
@[end if]@

@[if len(srv_specs) > 0]@
pub mod srv;
@[end if]@
@[end if]@
73 changes: 0 additions & 73 deletions rosidl_generator_rs/resource/msg.c.em

This file was deleted.

Loading