Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
69 changes: 0 additions & 69 deletions patch/ros-kilted-rosidl-generator-py.osx.patch

This file was deleted.

56 changes: 56 additions & 0 deletions patch/ros-kilted-rosidl-generator-py.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
diff --git a/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake b/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake
index de6a6c6..32eda28 100644
--- a/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake
+++ b/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake
@@ -35,6 +35,11 @@ set(Python3_FIND_UNVERSIONED_NAMES FIRST)

find_package(Python3 REQUIRED COMPONENTS Interpreter Development NumPy)

+# The Python C bindings library of an interface package is exported in
+# <pkg>_TARGETS__rosidl_generator_py instead of <pkg>_TARGETS, so that C/C++
+# consumers of the interface package don't link it.
+set(rosidl_generator_py_suffix "__rosidl_generator_py")
+
# Get a list of typesupport implementations from valid rmw implementations.
rosidl_generator_py_get_typesupports(_typesupport_impls)

@@ -160,10 +165,13 @@ add_dependencies(
${rosidl_generate_interfaces_TARGET}__rosidl_typesupport_c
)

+# This library is only linked by Python extension modules, which get the
+# CPython symbols from the interpreter that loads them, so it links
+# Python3::Module rather than libpython (Python3::Python).
target_link_libraries(
${_target_name_lib} PRIVATE
Python3::NumPy
- Python3::Python
+ Python3::Module
)
target_include_directories(${_target_name_lib}
PRIVATE
@@ -255,9 +263,22 @@ if(NOT rosidl_generate_interfaces_SKIP_INSTALL)
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)

- # Export this target so downstream interface packages can depend on it
+ # Export this target so downstream interface packages can depend on it, in
+ # <pkg>_TARGETS__rosidl_generator_py. Not with ament_export_targets(), which
+ # would also add it to <pkg>_TARGETS: install the export set and include it
+ # from a config extras file instead, which creates the imported target that
+ # rosidl_export_typesupport_targets() adds to the suffixed list.
+ install(
+ EXPORT export_${_target_name_lib}
+ DESTINATION share/${PROJECT_NAME}/cmake
+ NAMESPACE "${PROJECT_NAME}::"
+ FILE "export_${_target_name_lib}Export.cmake")
+ set(_py_extras_file
+ "${CMAKE_CURRENT_BINARY_DIR}/rosidl_generator_py/${_target_name_lib}-extras.cmake")
+ file(WRITE "${_py_extras_file}"
+ "include(\"\${${PROJECT_NAME}_DIR}/export_${_target_name_lib}Export.cmake\")\n")
+ list(APPEND ${PROJECT_NAME}_CONFIG_EXTRAS "${_py_extras_file}")
rosidl_export_typesupport_targets("${rosidl_generator_py_suffix}" "${_target_name_lib}")
- ament_export_targets(export_${_target_name_lib})
endif()

if(BUILD_TESTING AND rosidl_generate_interfaces_ADD_LINTER_TESTS)
4 changes: 1 addition & 3 deletions tests/ros-kilted-std-msgs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ tests:
# (https://github.com/RoboStack/ros-kilted/issues/76).
# cxx-compiler (unlike compiler('cxx')) sets no LDFLAGS, like a user's
# environment, so -Wl,--as-needed / -Wl,-dead_strip_dylibs can't hide it.
# TODO: back to unix once the osx rosidl_generator_py patch is replaced
# with the jazzy/rolling one (needs interface package rebuilds).
- if: linux
- if: unix
then:
script:
- cmake -S cpp_consumer -B build -G Ninja -DCMAKE_PREFIX_PATH="$PREFIX"
Expand Down
Loading