From cbf8fd0ec0e3c8bbdfaf0f572a814efdf8adad96 Mon Sep 17 00:00:00 2001 From: Daniel Mesham Date: Wed, 27 Sep 2023 10:11:46 +0200 Subject: [PATCH] Separate writing arguments files from the code generation and build Signed-off-by: Daniel Mesham --- rosidl_typesupport_fastrtps_c/CMakeLists.txt | 5 -- .../bin/rosidl_typesupport_fastrtps_c | 33 ---------- ...pport_fastrtps_c_generate_interfaces.cmake | 53 +-------------- ...pesupport_fastrtps_c_write_arguments.cmake | 66 +++++++++++++++++++ ...idl_typesupport_fastrtps_c-extras.cmake.in | 9 ++- .../rosidl_typesupport_fastrtps_c/__init__.py | 10 ++- .../CMakeLists.txt | 4 -- .../bin/rosidl_typesupport_fastrtps_cpp | 23 ------- ...ort_fastrtps_cpp_generate_interfaces.cmake | 59 +---------------- ...support_fastrtps_cpp_write_arguments.cmake | 61 +++++++++++++++++ ...l_typesupport_fastrtps_cpp-extras.cmake.in | 10 +-- .../__init__.py | 10 ++- 12 files changed, 152 insertions(+), 191 deletions(-) delete mode 100644 rosidl_typesupport_fastrtps_c/bin/rosidl_typesupport_fastrtps_c create mode 100644 rosidl_typesupport_fastrtps_c/cmake/rosidl_typesupport_fastrtps_c_write_arguments.cmake delete mode 100644 rosidl_typesupport_fastrtps_cpp/bin/rosidl_typesupport_fastrtps_cpp create mode 100644 rosidl_typesupport_fastrtps_cpp/cmake/rosidl_typesupport_fastrtps_cpp_write_arguments.cmake diff --git a/rosidl_typesupport_fastrtps_c/CMakeLists.txt b/rosidl_typesupport_fastrtps_c/CMakeLists.txt index 8cc8cf2..d7999dd 100644 --- a/rosidl_typesupport_fastrtps_c/CMakeLists.txt +++ b/rosidl_typesupport_fastrtps_c/CMakeLists.txt @@ -111,11 +111,6 @@ ament_package( CONFIG_EXTRAS "rosidl_typesupport_fastrtps_c-extras.cmake.in" ) -install( - PROGRAMS bin/rosidl_typesupport_fastrtps_c - DESTINATION lib/rosidl_typesupport_fastrtps_c -) - install( DIRECTORY cmake resource DESTINATION share/${PROJECT_NAME} diff --git a/rosidl_typesupport_fastrtps_c/bin/rosidl_typesupport_fastrtps_c b/rosidl_typesupport_fastrtps_c/bin/rosidl_typesupport_fastrtps_c deleted file mode 100644 index e872065..0000000 --- a/rosidl_typesupport_fastrtps_c/bin/rosidl_typesupport_fastrtps_c +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import os -import sys - -from rosidl_typesupport_fastrtps_c import generate_typesupport_fastrtps_c - - -def is_valid_file(parser, file_name): - if not os.path.exists(file_name): - parser.error("File does not exist: '{0}'".format(file_name)) - file_name_abs = os.path.abspath(file_name) - if not os.path.isfile(file_name_abs): - parser.error("Path exists but is not a file: '{0}'".format(file_name_abs)) - return file_name - - -def main(argv=sys.argv[1:]): - parser = argparse.ArgumentParser( - description='Generate the C interfaces for fastrtps.', - formatter_class=argparse.ArgumentDefaultsHelpFormatter) - parser.add_argument( - '--generator-arguments-file', - required=True, - help='The location of the file containing the generator arguments') - args = parser.parse_args(argv) - - generate_typesupport_fastrtps_c(args.generator_arguments_file) - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/rosidl_typesupport_fastrtps_c/cmake/rosidl_typesupport_fastrtps_c_generate_interfaces.cmake b/rosidl_typesupport_fastrtps_c/cmake/rosidl_typesupport_fastrtps_c_generate_interfaces.cmake index 4a761ad..c94cdf3 100644 --- a/rosidl_typesupport_fastrtps_c/cmake/rosidl_typesupport_fastrtps_c_generate_interfaces.cmake +++ b/rosidl_typesupport_fastrtps_c/cmake/rosidl_typesupport_fastrtps_c_generate_interfaces.cmake @@ -1,4 +1,4 @@ -# Copyright 2016-2018 Open Source Robotics Foundation, Inc. +# Copyright 2016-2023 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -38,57 +38,6 @@ foreach(_abs_idl_file ${rosidl_generate_interfaces_ABS_IDL_FILES}) "${_output_path}/${_parent_folder}/detail/${_header_name}__type_support_c.cpp") endforeach() -set(_dependency_files "") -set(_dependencies "") -foreach(_pkg_name ${rosidl_generate_interfaces_DEPENDENCY_PACKAGE_NAMES}) - foreach(_idl_file ${${_pkg_name}_IDL_FILES}) - set(_abs_idl_file "${${_pkg_name}_DIR}/../${_idl_file}") - normalize_path(_abs_idl_file "${_abs_idl_file}") - list(APPEND _dependency_files "${_abs_idl_file}") - list(APPEND _dependencies "${_pkg_name}:${_abs_idl_file}") - endforeach() -endforeach() - -set(target_dependencies - "${rosidl_typesupport_fastrtps_c_BIN}" - ${rosidl_typesupport_fastrtps_c_GENERATOR_FILES} - "${rosidl_typesupport_fastrtps_c_TEMPLATE_DIR}/idl__rosidl_typesupport_fastrtps_c.h.em" - "${rosidl_typesupport_fastrtps_c_TEMPLATE_DIR}/idl__type_support_c.cpp.em" - "${rosidl_typesupport_fastrtps_c_TEMPLATE_DIR}/msg__rosidl_typesupport_fastrtps_c.h.em" - "${rosidl_typesupport_fastrtps_c_TEMPLATE_DIR}/msg__type_support_c.cpp.em" - "${rosidl_typesupport_fastrtps_c_TEMPLATE_DIR}/srv__rosidl_typesupport_fastrtps_c.h.em" - "${rosidl_typesupport_fastrtps_c_TEMPLATE_DIR}/srv__type_support_c.cpp.em" - ${rosidl_generate_interfaces_ABS_IDL_FILES} - ${_dependency_files}) -foreach(dep ${target_dependencies}) - if(NOT EXISTS "${dep}") - message(FATAL_ERROR "Target dependency '${dep}' does not exist") - endif() -endforeach() - -set(generator_arguments_file "${CMAKE_CURRENT_BINARY_DIR}/rosidl_typesupport_fastrtps_c__arguments.json") -rosidl_write_generator_arguments( - "${generator_arguments_file}" - PACKAGE_NAME "${PROJECT_NAME}" - IDL_TUPLES "${rosidl_generate_interfaces_IDL_TUPLES}" - ROS_INTERFACE_DEPENDENCIES "${_dependencies}" - OUTPUT_DIR "${_output_path}" - TEMPLATE_DIR "${rosidl_typesupport_fastrtps_c_TEMPLATE_DIR}" - TARGET_DEPENDENCIES ${target_dependencies} -) - -find_package(Python3 REQUIRED COMPONENTS Interpreter) - -add_custom_command( - OUTPUT ${_generated_files} - COMMAND Python3::Interpreter - ARGS ${rosidl_typesupport_fastrtps_c_BIN} - --generator-arguments-file "${generator_arguments_file}" - DEPENDS ${target_dependencies} - COMMENT "Generating C type support for eProsima Fast-RTPS" - VERBATIM -) - # generate header to switch between export and import for a specific package set(_visibility_control_file "${_output_path}/msg/rosidl_typesupport_fastrtps_c__visibility_control.h") diff --git a/rosidl_typesupport_fastrtps_c/cmake/rosidl_typesupport_fastrtps_c_write_arguments.cmake b/rosidl_typesupport_fastrtps_c/cmake/rosidl_typesupport_fastrtps_c_write_arguments.cmake new file mode 100644 index 0000000..b057bdc --- /dev/null +++ b/rosidl_typesupport_fastrtps_c/cmake/rosidl_typesupport_fastrtps_c_write_arguments.cmake @@ -0,0 +1,66 @@ +# Copyright 2023 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(_output_path "${CMAKE_CURRENT_BINARY_DIR}/rosidl_typesupport_fastrtps_c/${PROJECT_NAME}") +set(_generated_files "") +foreach(_abs_idl_file ${rosidl_generate_interfaces_ABS_IDL_FILES}) + get_filename_component(_parent_folder "${_abs_idl_file}" DIRECTORY) + get_filename_component(_parent_folder "${_parent_folder}" NAME) + get_filename_component(_idl_name "${_abs_idl_file}" NAME_WE) + string_camel_case_to_lower_case_underscore("${_idl_name}" _header_name) + list(APPEND _generated_files + "${_output_path}/${_parent_folder}/detail/${_header_name}__rosidl_typesupport_fastrtps_c.h" + "${_output_path}/${_parent_folder}/detail/${_header_name}__type_support_c.cpp") +endforeach() + +set(_dependency_files "") +set(_dependencies "") +foreach(_pkg_name ${rosidl_generate_interfaces_DEPENDENCY_PACKAGE_NAMES}) + foreach(_idl_file ${${_pkg_name}_IDL_FILES}) + set(_abs_idl_file "${${_pkg_name}_DIR}/../${_idl_file}") + normalize_path(_abs_idl_file "${_abs_idl_file}") + list(APPEND _dependency_files "${_abs_idl_file}") + list(APPEND _dependencies "${_pkg_name}:${_abs_idl_file}") + endforeach() +endforeach() + +set(target_dependencies + ${rosidl_typesupport_fastrtps_c_GENERATOR_FILES} + "${rosidl_typesupport_fastrtps_c_TEMPLATE_DIR}/idl__rosidl_typesupport_fastrtps_c.h.em" + "${rosidl_typesupport_fastrtps_c_TEMPLATE_DIR}/idl__type_support_c.cpp.em" + "${rosidl_typesupport_fastrtps_c_TEMPLATE_DIR}/msg__rosidl_typesupport_fastrtps_c.h.em" + "${rosidl_typesupport_fastrtps_c_TEMPLATE_DIR}/msg__type_support_c.cpp.em" + "${rosidl_typesupport_fastrtps_c_TEMPLATE_DIR}/srv__rosidl_typesupport_fastrtps_c.h.em" + "${rosidl_typesupport_fastrtps_c_TEMPLATE_DIR}/srv__type_support_c.cpp.em" + ${rosidl_generate_interfaces_ABS_IDL_FILES} + ${_dependency_files}) +foreach(dep ${target_dependencies}) + if(NOT EXISTS "${dep}") + message(FATAL_ERROR "Target dependency '${dep}' does not exist") + endif() +endforeach() + +set(generator_arguments_file "${CMAKE_CURRENT_BINARY_DIR}/rosidl_typesupport_fastrtps_c__arguments.json") +rosidl_write_generator_arguments( + "${generator_arguments_file}" + PACKAGE_NAME "${PROJECT_NAME}" + IDL_TUPLES "${rosidl_generate_interfaces_IDL_TUPLES}" + ROS_INTERFACE_DEPENDENCIES "${_dependencies}" + OUTPUT_DIR "${_output_path}" + TEMPLATE_DIR "${rosidl_typesupport_fastrtps_c_TEMPLATE_DIR}" + TARGET_DEPENDENCIES ${target_dependencies} + GENERATOR_FILES "${rosidl_typesupport_fastrtps_c_GENERATOR_FILES}" +) + +list(APPEND rosidl_generator_arguments_files ${generator_arguments_file}) diff --git a/rosidl_typesupport_fastrtps_c/rosidl_typesupport_fastrtps_c-extras.cmake.in b/rosidl_typesupport_fastrtps_c/rosidl_typesupport_fastrtps_c-extras.cmake.in index 270c02a..7f3c231 100644 --- a/rosidl_typesupport_fastrtps_c/rosidl_typesupport_fastrtps_c-extras.cmake.in +++ b/rosidl_typesupport_fastrtps_c/rosidl_typesupport_fastrtps_c-extras.cmake.in @@ -15,16 +15,15 @@ else() # Find it first so it registers it's extensions first find_package(rosidl_generator_c REQUIRED) + ament_register_extension( + "rosidl_write_generator_arguments_extensions" + "rosidl_typesupport_fastrtps_c" + "rosidl_typesupport_fastrtps_c_write_arguments.cmake") ament_register_extension( "rosidl_generate_idl_interfaces" "rosidl_typesupport_fastrtps_c" "rosidl_typesupport_fastrtps_c_generate_interfaces.cmake") - set(rosidl_typesupport_fastrtps_c_BIN - "${rosidl_typesupport_fastrtps_c_DIR}/../../../lib/rosidl_typesupport_fastrtps_c/rosidl_typesupport_fastrtps_c") - normalize_path(rosidl_typesupport_fastrtps_c_BIN - "${rosidl_typesupport_fastrtps_c_BIN}") - set(rosidl_typesupport_fastrtps_c_GENERATOR_FILES "${rosidl_typesupport_fastrtps_c_DIR}/../../../@PYTHON_INSTALL_DIR@/rosidl_typesupport_fastrtps_c/__init__.py") normalize_path(rosidl_typesupport_fastrtps_c_GENERATOR_FILES diff --git a/rosidl_typesupport_fastrtps_c/rosidl_typesupport_fastrtps_c/__init__.py b/rosidl_typesupport_fastrtps_c/rosidl_typesupport_fastrtps_c/__init__.py index d5d250e..dcfe67d 100644 --- a/rosidl_typesupport_fastrtps_c/rosidl_typesupport_fastrtps_c/__init__.py +++ b/rosidl_typesupport_fastrtps_c/rosidl_typesupport_fastrtps_c/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2016-2018 Open Source Robotics Foundation, Inc. +# Copyright 2016-2023 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,10 +15,14 @@ from rosidl_pycommon import generate_files -def generate_typesupport_fastrtps_c(generator_arguments_file): - mapping = { +def get_template_mapping(): + return { 'idl__rosidl_typesupport_fastrtps_c.h.em': 'detail/%s__rosidl_typesupport_fastrtps_c.h', 'idl__type_support_c.cpp.em': 'detail/%s__type_support_c.cpp', } + + +def generate_typesupport_fastrtps_c(generator_arguments_file): + mapping = get_template_mapping() return generate_files(generator_arguments_file, mapping) diff --git a/rosidl_typesupport_fastrtps_cpp/CMakeLists.txt b/rosidl_typesupport_fastrtps_cpp/CMakeLists.txt index 1552f88..998b1c5 100644 --- a/rosidl_typesupport_fastrtps_cpp/CMakeLists.txt +++ b/rosidl_typesupport_fastrtps_cpp/CMakeLists.txt @@ -117,10 +117,6 @@ ament_package( CONFIG_EXTRAS "rosidl_typesupport_fastrtps_cpp-extras.cmake.in" ) -install( - PROGRAMS bin/rosidl_typesupport_fastrtps_cpp - DESTINATION lib/rosidl_typesupport_fastrtps_cpp -) install( DIRECTORY cmake resource DESTINATION share/${PROJECT_NAME} diff --git a/rosidl_typesupport_fastrtps_cpp/bin/rosidl_typesupport_fastrtps_cpp b/rosidl_typesupport_fastrtps_cpp/bin/rosidl_typesupport_fastrtps_cpp deleted file mode 100644 index b394bab..0000000 --- a/rosidl_typesupport_fastrtps_cpp/bin/rosidl_typesupport_fastrtps_cpp +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import sys - -from rosidl_typesupport_fastrtps_cpp import generate_cpp - - -def main(argv=sys.argv[1:]): - parser = argparse.ArgumentParser( - description='Generate the C++ interfaces for fastrtps.', - formatter_class=argparse.ArgumentDefaultsHelpFormatter) - parser.add_argument( - '--generator-arguments-file', - required=True, - help='The location of the file containing the generator arguments') - args = parser.parse_args(argv) - - generate_cpp(args.generator_arguments_file) - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/rosidl_typesupport_fastrtps_cpp/cmake/rosidl_typesupport_fastrtps_cpp_generate_interfaces.cmake b/rosidl_typesupport_fastrtps_cpp/cmake/rosidl_typesupport_fastrtps_cpp_generate_interfaces.cmake index 4b62618..8bd5769 100644 --- a/rosidl_typesupport_fastrtps_cpp/cmake/rosidl_typesupport_fastrtps_cpp_generate_interfaces.cmake +++ b/rosidl_typesupport_fastrtps_cpp/cmake/rosidl_typesupport_fastrtps_cpp_generate_interfaces.cmake @@ -1,4 +1,4 @@ -# Copyright 2014-2015 Open Source Robotics Foundation, Inc. +# Copyright 2014-2023 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -43,63 +43,6 @@ foreach(_abs_idl_file ${rosidl_generate_interfaces_ABS_IDL_FILES}) ) endforeach() -# Create a list of IDL files from other packages that this generator should depend on -set(_dependency_files "") -set(_dependencies "") -foreach(_pkg_name ${rosidl_generate_interfaces_DEPENDENCY_PACKAGE_NAMES}) - foreach(_idl_file ${${_pkg_name}_IDL_FILES}) - # ${{_pkg_name}_DIR} is absolute path ending in 'share//cmake', so go back one - # directory for IDL files - set(_abs_idl_file "${${_pkg_name}_DIR}/../${_idl_file}") - normalize_path(_abs_idl_file "${_abs_idl_file}") - list(APPEND _dependency_files "${_abs_idl_file}") - list(APPEND _dependencies "${_pkg_name}:${_abs_idl_file}") - endforeach() -endforeach() - -# Create a list of templates and source files this generator uses, and check that they exist -set(target_dependencies - "${rosidl_typesupport_fastrtps_cpp_BIN}" - ${rosidl_typesupport_fastrtps_cpp_GENERATOR_FILES} - "${rosidl_typesupport_fastrtps_cpp_TEMPLATE_DIR}/idl__rosidl_typesupport_fastrtps_cpp.hpp.em" - "${rosidl_typesupport_fastrtps_cpp_TEMPLATE_DIR}/idl__type_support.cpp.em" - "${rosidl_typesupport_fastrtps_cpp_TEMPLATE_DIR}/msg__rosidl_typesupport_fastrtps_cpp.hpp.em" - "${rosidl_typesupport_fastrtps_cpp_TEMPLATE_DIR}/msg__type_support.cpp.em" - "${rosidl_typesupport_fastrtps_cpp_TEMPLATE_DIR}/srv__rosidl_typesupport_fastrtps_cpp.hpp.em" - "${rosidl_typesupport_fastrtps_cpp_TEMPLATE_DIR}/srv__type_support.cpp.em" - ${rosidl_generate_interfaces_ABS_IDL_FILES} - ${_dependency_files}) -foreach(dep ${target_dependencies}) - if(NOT EXISTS "${dep}") - message(FATAL_ERROR "Target dependency '${dep}' does not exist") - endif() -endforeach() - -# Write all this to a file to work around command line length limitations on some platforms -set(generator_arguments_file "${CMAKE_CURRENT_BINARY_DIR}/rosidl_typesupport_fastrtps_cpp__arguments.json") -rosidl_write_generator_arguments( - "${generator_arguments_file}" - PACKAGE_NAME "${PROJECT_NAME}" - IDL_TUPLES "${rosidl_generate_interfaces_IDL_TUPLES}" - ROS_INTERFACE_DEPENDENCIES "${_dependencies}" - OUTPUT_DIR "${_output_path}" - TEMPLATE_DIR "${rosidl_typesupport_fastrtps_cpp_TEMPLATE_DIR}" - TARGET_DEPENDENCIES ${target_dependencies} -) - -find_package(Python3 REQUIRED COMPONENTS Interpreter) - -# Add a command that invokes generator at build time -add_custom_command( - OUTPUT ${_generated_files} - COMMAND Python3::Interpreter - ARGS ${rosidl_typesupport_fastrtps_cpp_BIN} - --generator-arguments-file "${generator_arguments_file}" - DEPENDS ${target_dependencies} - COMMENT "Generating C++ type support for eProsima Fast-RTPS" - VERBATIM -) - # generate header to switch between export and import for a specific package set(_visibility_control_file "${_output_path}/msg/rosidl_typesupport_fastrtps_cpp__visibility_control.h") diff --git a/rosidl_typesupport_fastrtps_cpp/cmake/rosidl_typesupport_fastrtps_cpp_write_arguments.cmake b/rosidl_typesupport_fastrtps_cpp/cmake/rosidl_typesupport_fastrtps_cpp_write_arguments.cmake new file mode 100644 index 0000000..77e6fc9 --- /dev/null +++ b/rosidl_typesupport_fastrtps_cpp/cmake/rosidl_typesupport_fastrtps_cpp_write_arguments.cmake @@ -0,0 +1,61 @@ +# Copyright 2023 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(_output_path "${CMAKE_CURRENT_BINARY_DIR}/rosidl_typesupport_fastrtps_cpp/${PROJECT_NAME}") + +# Create a list of IDL files from other packages that this generator should depend on +set(_dependency_files "") +set(_dependencies "") +foreach(_pkg_name ${rosidl_generate_interfaces_DEPENDENCY_PACKAGE_NAMES}) + foreach(_idl_file ${${_pkg_name}_IDL_FILES}) + # ${{_pkg_name}_DIR} is absolute path ending in 'share//cmake', so go back one + # directory for IDL files + set(_abs_idl_file "${${_pkg_name}_DIR}/../${_idl_file}") + normalize_path(_abs_idl_file "${_abs_idl_file}") + list(APPEND _dependency_files "${_abs_idl_file}") + list(APPEND _dependencies "${_pkg_name}:${_abs_idl_file}") + endforeach() +endforeach() + +# Create a list of templates and source files this generator uses, and check that they exist +set(target_dependencies + ${rosidl_typesupport_fastrtps_cpp_GENERATOR_FILES} + "${rosidl_typesupport_fastrtps_cpp_TEMPLATE_DIR}/idl__rosidl_typesupport_fastrtps_cpp.hpp.em" + "${rosidl_typesupport_fastrtps_cpp_TEMPLATE_DIR}/idl__type_support.cpp.em" + "${rosidl_typesupport_fastrtps_cpp_TEMPLATE_DIR}/msg__rosidl_typesupport_fastrtps_cpp.hpp.em" + "${rosidl_typesupport_fastrtps_cpp_TEMPLATE_DIR}/msg__type_support.cpp.em" + "${rosidl_typesupport_fastrtps_cpp_TEMPLATE_DIR}/srv__rosidl_typesupport_fastrtps_cpp.hpp.em" + "${rosidl_typesupport_fastrtps_cpp_TEMPLATE_DIR}/srv__type_support.cpp.em" + ${rosidl_generate_interfaces_ABS_IDL_FILES} + ${_dependency_files}) +foreach(dep ${target_dependencies}) + if(NOT EXISTS "${dep}") + message(FATAL_ERROR "Target dependency '${dep}' does not exist") + endif() +endforeach() + +# Write all this to a file to work around command line length limitations on some platforms +set(generator_arguments_file "${CMAKE_CURRENT_BINARY_DIR}/rosidl_typesupport_fastrtps_cpp__arguments.json") +rosidl_write_generator_arguments( + "${generator_arguments_file}" + PACKAGE_NAME "${PROJECT_NAME}" + IDL_TUPLES "${rosidl_generate_interfaces_IDL_TUPLES}" + ROS_INTERFACE_DEPENDENCIES "${_dependencies}" + OUTPUT_DIR "${_output_path}" + TEMPLATE_DIR "${rosidl_typesupport_fastrtps_cpp_TEMPLATE_DIR}" + TARGET_DEPENDENCIES ${target_dependencies} + GENERATOR_FILES "${rosidl_typesupport_fastrtps_cpp_GENERATOR_FILES}" +) + +list(APPEND rosidl_generator_arguments_files ${generator_arguments_file}) diff --git a/rosidl_typesupport_fastrtps_cpp/rosidl_typesupport_fastrtps_cpp-extras.cmake.in b/rosidl_typesupport_fastrtps_cpp/rosidl_typesupport_fastrtps_cpp-extras.cmake.in index 913b573..0e4c630 100644 --- a/rosidl_typesupport_fastrtps_cpp/rosidl_typesupport_fastrtps_cpp-extras.cmake.in +++ b/rosidl_typesupport_fastrtps_cpp/rosidl_typesupport_fastrtps_cpp-extras.cmake.in @@ -16,16 +16,16 @@ else() # Find it first so it registers it's extensions first find_package(rosidl_generator_cpp REQUIRED) + ament_register_extension( + "rosidl_write_generator_arguments_extensions" + "rosidl_typesupport_fastrtps_cpp" + "rosidl_typesupport_fastrtps_cpp_write_arguments.cmake") + ament_register_extension( "rosidl_generate_idl_interfaces" "rosidl_typesupport_fastrtps_cpp" "rosidl_typesupport_fastrtps_cpp_generate_interfaces.cmake") - set(rosidl_typesupport_fastrtps_cpp_BIN - "${rosidl_typesupport_fastrtps_cpp_DIR}/../../../lib/rosidl_typesupport_fastrtps_cpp/rosidl_typesupport_fastrtps_cpp") - normalize_path(rosidl_typesupport_fastrtps_cpp_BIN - "${rosidl_typesupport_fastrtps_cpp_BIN}") - set(rosidl_typesupport_fastrtps_cpp_GENERATOR_FILES "${rosidl_typesupport_fastrtps_cpp_DIR}/../../../@PYTHON_INSTALL_DIR@/rosidl_typesupport_fastrtps_cpp/__init__.py") normalize_path(rosidl_typesupport_fastrtps_cpp_GENERATOR_FILES diff --git a/rosidl_typesupport_fastrtps_cpp/rosidl_typesupport_fastrtps_cpp/__init__.py b/rosidl_typesupport_fastrtps_cpp/rosidl_typesupport_fastrtps_cpp/__init__.py index e971fac..1a4c7ab 100644 --- a/rosidl_typesupport_fastrtps_cpp/rosidl_typesupport_fastrtps_cpp/__init__.py +++ b/rosidl_typesupport_fastrtps_cpp/rosidl_typesupport_fastrtps_cpp/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2014 Open Source Robotics Foundation, Inc. +# Copyright 2023 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,10 +15,14 @@ from rosidl_pycommon import generate_files -def generate_cpp(generator_arguments_file): - mapping = { +def get_template_mapping(): + return { 'idl__rosidl_typesupport_fastrtps_cpp.hpp.em': 'detail/%s__rosidl_typesupport_fastrtps_cpp.hpp', 'idl__type_support.cpp.em': 'detail/dds_fastrtps/%s__type_support.cpp', } + + +def generate_cpp(generator_arguments_file): + mapping = get_template_mapping() return generate_files(generator_arguments_file, mapping)