Skip to content

Commit

Permalink
Unify generate_substitutions_from_package
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jspricke committed Aug 1, 2021
1 parent 8e16f28 commit 0d722f1
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 51 deletions.
1 change: 1 addition & 0 deletions bloom/generators/debian/generate_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
51 changes: 50 additions & 1 deletion bloom/generators/debian/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 []
Expand Down Expand Up @@ -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


Expand Down
52 changes: 2 additions & 50 deletions bloom/generators/rosdebian.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@

from bloom.logging import info

from bloom.rosdistro_api import get_index

from bloom.util import get_distro_list_prompt


Expand Down Expand Up @@ -87,52 +85,6 @@ def fallback_resolver(key, peer_packages, rosdistro=self.rosdistro):
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):
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit 0d722f1

Please sign in to comment.