Skip to content

Commit 2ac1e70

Browse files
committed
update ros idl generate-py patch
1 parent 715930b commit 2ac1e70

File tree

1 file changed

+41
-17
lines changed

1 file changed

+41
-17
lines changed

patch/ros-humble-rosidl-generator-py.patch

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
1+
diff --git a/cmake/register_py.cmake b/cmake/register_py.cmake
2+
index f31c534..4671ec0 100644
3+
--- a/cmake/register_py.cmake
4+
+++ b/cmake/register_py.cmake
5+
@@ -14,6 +14,7 @@
6+
7+
macro(rosidl_generator_py_extras BIN GENERATOR_FILES TEMPLATE_DIR)
8+
find_package(ament_cmake_core QUIET REQUIRED)
9+
+
10+
# Make sure extension points are registered in order
11+
find_package(rosidl_generator_c QUIET REQUIRED)
12+
find_package(rosidl_typesupport_c QUIET REQUIRED)
113
diff --git a/cmake/rosidl_generator_py_generate_interfaces.cmake b/cmake/rosidl_generator_py_generate_interfaces.cmake
2-
index a6d8263..ecae76b 100644
14+
index a6d8263..0f7a12a 100644
315
--- a/cmake/rosidl_generator_py_generate_interfaces.cmake
416
+++ b/cmake/rosidl_generator_py_generate_interfaces.cmake
5-
@@ -21,6 +21,7 @@ find_package(PythonInterp 3.6 REQUIRED)
17+
@@ -17,10 +17,9 @@ find_package(rosidl_runtime_c REQUIRED)
18+
find_package(rosidl_typesupport_c REQUIRED)
19+
find_package(rosidl_typesupport_interface REQUIRED)
620

21+
-find_package(PythonInterp 3.6 REQUIRED)
22+
-
723
find_package(python_cmake_module REQUIRED)
8-
find_package(PythonExtra MODULE REQUIRED)
9-
+find_package(Python3 REQUIRED COMPONENTS Development NumPy)
24+
-find_package(PythonExtra MODULE REQUIRED)
25+
+find_package(PythonExtra REQUIRED)
26+
+find_package(Python3 REQUIRED COMPONENTS Interpreter Development NumPy)
1027

1128
# Get a list of typesupport implementations from valid rmw implementations.
1229
rosidl_generator_py_get_typesupports(_typesupport_impls)
13-
@@ -165,52 +166,27 @@ set(rosidl_generator_py_suffix "__rosidl_generator_py")
30+
@@ -165,52 +164,26 @@ set(rosidl_generator_py_suffix "__rosidl_generator_py")
1431
set(_target_name_lib "${rosidl_generate_interfaces_TARGET}${rosidl_generator_py_suffix}")
1532
add_library(${_target_name_lib} SHARED ${_generated_c_files})
1633
target_link_libraries(${_target_name_lib}
@@ -31,13 +48,13 @@ index a6d8263..ecae76b 100644
3148
${CMAKE_CURRENT_BINARY_DIR}/rosidl_generator_c
3249
${CMAKE_CURRENT_BINARY_DIR}/rosidl_generator_py
3350
- ${PythonExtra_INCLUDE_DIRS}
34-
)
35-
51+
-)
52+
-
3653
-# Check if numpy is in the include path
3754
-find_file(_numpy_h numpy/numpyconfig.h
3855
- PATHS ${PythonExtra_INCLUDE_DIRS}
39-
-)
40-
-
56+
)
57+
4158
-if(APPLE OR WIN32 OR NOT _numpy_h)
4259
- # add include directory for numpy headers
4360
- set(_python_code
@@ -57,20 +74,27 @@ index a6d8263..ecae76b 100644
5774
- endif()
5875
- message(STATUS "Using numpy include directory: ${_output}")
5976
- target_include_directories(${_target_name_lib} PUBLIC "${_output}")
60-
-endif()
6177
+if(APPLE)
6278
+set_target_properties(${_target_name_lib} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
63-
+else()
64-
+target_link_libraries(${_target_name_lib} PUBLIC Python3::NumPy Python3::Module Python3::Python)
65-
+endif()
79+
endif()
80+
+target_link_libraries(${_target_name_lib} PRIVATE Python3::NumPy Python3::Python)
6681

6782
rosidl_get_typesupport_target(c_typesupport_target "${rosidl_generate_interfaces_TARGET}" "rosidl_typesupport_c")
6883
-target_link_libraries(${_target_name_lib} ${c_typesupport_target})
6984
+target_link_libraries(${_target_name_lib} PUBLIC ${c_typesupport_target})
7085

7186
foreach(_typesupport_impl ${_typesupport_impls})
7287
find_package(${_typesupport_impl} REQUIRED)
73-
@@ -245,27 +217,28 @@ foreach(_typesupport_impl ${_typesupport_impls})
88+
@@ -223,7 +196,7 @@ foreach(_typesupport_impl ${_typesupport_impls})
89+
set(_pyext_suffix "__pyext")
90+
set(_target_name "${PROJECT_NAME}__${_typesupport_impl}${_pyext_suffix}")
91+
92+
- add_library(${_target_name} SHARED
93+
+ python3_add_library(${_target_name} SHARED
94+
${_generated_extension_${_typesupport_impl}_files}
95+
)
96+
add_dependencies(
97+
@@ -245,27 +218,28 @@ foreach(_typesupport_impl ${_typesupport_impls})
7498
endif()
7599
target_link_libraries(
76100
${_target_name}
@@ -103,7 +127,7 @@ index a6d8263..ecae76b 100644
103127
${_pkg_name}
104128
)
105129
endforeach()
106-
@@ -273,7 +246,7 @@ foreach(_typesupport_impl ${_typesupport_impls})
130+
@@ -273,7 +247,7 @@ foreach(_typesupport_impl ${_typesupport_impls})
107131
add_dependencies(${_target_name}
108132
${rosidl_generate_interfaces_TARGET}__${_typesupport_impl}
109133
)
@@ -112,7 +136,7 @@ index a6d8263..ecae76b 100644
112136
"rosidl_runtime_c"
113137
"rosidl_generator_py"
114138
)
115-
@@ -288,7 +261,7 @@ set(PYTHON_EXECUTABLE ${_PYTHON_EXECUTABLE})
139+
@@ -288,7 +262,7 @@ set(PYTHON_EXECUTABLE ${_PYTHON_EXECUTABLE})
116140

117141
# Depend on rosidl_generator_py generated targets from our dependencies
118142
foreach(_pkg_name ${rosidl_generate_interfaces_DEPENDENCY_PACKAGE_NAMES})
@@ -121,7 +145,7 @@ index a6d8263..ecae76b 100644
121145
endforeach()
122146

123147
set_lib_properties("")
124-
@@ -352,4 +325,4 @@ if(BUILD_TESTING AND rosidl_generate_interfaces_ADD_LINTER_TESTS)
148+
@@ -352,4 +326,4 @@ if(BUILD_TESTING AND rosidl_generate_interfaces_ADD_LINTER_TESTS)
125149
MAX_LINE_LENGTH 0
126150
"${_output_path}")
127151
endif()

0 commit comments

Comments
 (0)