From aace9de1f8fee45547ed16533a943dd44dd70b1d Mon Sep 17 00:00:00 2001 From: Jochen Sprickerhof Date: Sun, 1 Aug 2021 11:08:43 +0200 Subject: [PATCH] Unify generate_substitutions_from_package Some ROS2 specific additions where added to the $ git-bloom-generate rosdebian call. This moves them into the common generate_substitutions_from_package and thus making it available to $ bloom-generate [ros]debian as well. Note that fallback_resolver is now a required argument. --- bloom/generators/debian/generate_cmd.py | 1 + bloom/generators/debian/generator.py | 51 ++++++++++++++++++++++- bloom/generators/rosdebian.py | 54 ++----------------------- 3 files changed, 54 insertions(+), 52 deletions(-) diff --git a/bloom/generators/debian/generate_cmd.py b/bloom/generators/debian/generate_cmd.py index 5b919ace..6a7fed15 100644 --- a/bloom/generators/debian/generate_cmd.py +++ b/bloom/generators/debian/generate_cmd.py @@ -86,6 +86,7 @@ def get_subs(pkg, os_name, os_version, ros_distro, deb_inc=0, native=False): os_name, os_version, ros_distro, + fallback_resolver=lambda name, _rosdistro: name, deb_inc=deb_inc, native=native ) diff --git a/bloom/generators/debian/generator.py b/bloom/generators/debian/generator.py index 23a9afb0..74eefa91 100644 --- a/bloom/generators/debian/generator.py +++ b/bloom/generators/debian/generator.py @@ -83,6 +83,8 @@ from bloom.packages import get_package_data +from bloom.rosdistro_api import get_index + from bloom.util import code from bloom.util import to_unicode from bloom.util import execute_command @@ -285,11 +287,11 @@ def generate_substitutions_from_package( os_name, os_version, ros_distro, + fallback_resolver, installation_prefix='/usr', deb_inc=0, peer_packages=None, releaser_history=None, - fallback_resolver=None, native=False ): peer_packages = peer_packages or [] @@ -472,6 +474,53 @@ def convertToUnicode(obj): for item in data.items(): data[item[0]] = convertToUnicode(item[1]) + data['Rosdistro'] = ros_distro + data['Package'] = fallback_resolver(data['Package'], ros_distro) + + # ROS 2 specific bloom extensions. + ros2_distros = [ + name for name, values in get_index().distributions.items() + if values.get('distribution_type') == 'ros2'] + if ros_distro in ros2_distros: + # Add ros-workspace package as a dependency to any package other + # than ros_workspace and its dependencies. + if package.name not in ['ament_cmake_core', 'ament_package', 'ros_workspace']: + workspace_pkg_name = fallback_resolver('ros-workspace', ros_distro) + data['BuildDepends'].append(workspace_pkg_name) + data['Depends'].append(workspace_pkg_name) + + # Add packages necessary to build vendor typesupport for rosidl_interface_packages to their + # build dependencies. + if ros_distro in ros2_distros and \ + ros_distro not in ('r2b2', 'r2b3', 'ardent') and \ + 'rosidl_interface_packages' in [p.name for p in package.member_of_groups]: + ROS2_VENDOR_TYPESUPPORT_DEPENDENCIES = [ + 'rosidl-typesupport-fastrtps-c', + 'rosidl-typesupport-fastrtps-cpp', + ] + + # Connext was changed to a new rmw that doesn't require typesupport after Foxy + if ros_distro in ('bouncy', 'crystal', 'dashing', 'eloquent', 'foxy'): + ROS2_VENDOR_TYPESUPPORT_DEPENDENCIES.extend([ + 'rosidl-typesupport-connext-c', + 'rosidl-typesupport-connext-cpp', + ]) + + # OpenSplice was dropped after Eloquent. + # rmw implementations are required as dependencies up to Eloquent. + if ros_distro in ('bouncy', 'crystal', 'dashing', 'eloquent'): + ROS2_VENDOR_TYPESUPPORT_DEPENDENCIES.extend([ + 'rmw-connext-cpp', + 'rmw-fastrtps-cpp', + 'rmw-implementation', + 'rmw-opensplice-cpp', + 'rosidl-typesupport-opensplice-c', + 'rosidl-typesupport-opensplice-cpp', + ]) + + data['BuildDepends'] += [ + fallback_resolver(name, ros_distro) for name in ROS2_VENDOR_TYPESUPPORT_DEPENDENCIES] + return data diff --git a/bloom/generators/rosdebian.py b/bloom/generators/rosdebian.py index e0b23bac..e1f1b598 100644 --- a/bloom/generators/rosdebian.py +++ b/bloom/generators/rosdebian.py @@ -44,8 +44,6 @@ from bloom.logging import info -from bloom.rosdistro_api import get_index - from bloom.util import get_distro_list_prompt @@ -81,58 +79,12 @@ def fallback_resolver(key, peer_packages, rosdistro=self.rosdistro): self.os_name, debian_distro, self.rosdistro, + fallback_resolver, self.install_prefix, self.debian_inc, [p.name for p in self.packages.values()], releaser_history=releaser_history, - fallback_resolver=fallback_resolver ) - subs['Rosdistro'] = self.rosdistro - subs['Package'] = rosify_package_name(subs['Package'], self.rosdistro) - - # ROS 2 specific bloom extensions. - ros2_distros = [ - name for name, values in get_index().distributions.items() - if values.get('distribution_type') == 'ros2'] - if self.rosdistro in ros2_distros: - # Add ros-workspace package as a dependency to any package other - # than ros_workspace and its dependencies. - if package.name not in ['ament_cmake_core', 'ament_package', 'ros_workspace']: - workspace_pkg_name = rosify_package_name('ros-workspace', self.rosdistro) - subs['BuildDepends'].append(workspace_pkg_name) - subs['Depends'].append(workspace_pkg_name) - - # Add packages necessary to build vendor typesupport for rosidl_interface_packages to their - # build dependencies. - if self.rosdistro in ros2_distros and \ - self.rosdistro not in ('r2b2', 'r2b3', 'ardent') and \ - 'rosidl_interface_packages' in [p.name for p in package.member_of_groups]: - ROS2_VENDOR_TYPESUPPORT_DEPENDENCIES = [ - 'rosidl-typesupport-fastrtps-c', - 'rosidl-typesupport-fastrtps-cpp', - ] - - # Connext was changed to a new rmw that doesn't require typesupport after Foxy - if self.rosdistro in ('bouncy', 'crystal', 'dashing', 'eloquent', 'foxy'): - ROS2_VENDOR_TYPESUPPORT_DEPENDENCIES.extend([ - 'rosidl-typesupport-connext-c', - 'rosidl-typesupport-connext-cpp', - ]) - - # OpenSplice was dropped after Eloquent. - # rmw implementations are required as dependencies up to Eloquent. - if self.rosdistro in ('bouncy', 'crystal', 'dashing', 'eloquent'): - ROS2_VENDOR_TYPESUPPORT_DEPENDENCIES.extend([ - 'rmw-connext-cpp', - 'rmw-fastrtps-cpp', - 'rmw-implementation', - 'rmw-opensplice-cpp', - 'rosidl-typesupport-opensplice-c', - 'rosidl-typesupport-opensplice-cpp', - ]) - - subs['BuildDepends'] += [ - rosify_package_name(name, self.rosdistro) for name in ROS2_VENDOR_TYPESUPPORT_DEPENDENCIES] return subs def generate_branching_arguments(self, package, branch): @@ -162,9 +114,9 @@ def get_subs(pkg, os_name, os_version, ros_distro, deb_inc, native): ros_distro, RosDebianGenerator.default_install_prefix + ros_distro, deb_inc=deb_inc, - native=native + native=native, + fallback_resolver=rosify_package_name ) - subs['Package'] = rosify_package_name(subs['Package'], ros_distro) return subs