Skip to content
Snippets Groups Projects
Commit 2f4d85e0 authored by Daniel Stonier's avatar Daniel Stonier
Browse files

support for a message artifact command line generator.

parent 65d5c224
No related branches found
No related tags found
No related merge requests found
......@@ -10,3 +10,4 @@ from create_android_project import create_android_project
from create_rosjava_project import create_rosjava_project, create_rosjava_msg_project, create_rosjava_library_project
from utils import which
from release import scrape_for_release_message_packages
import catkin
#!/usr/bin/env python
##############################################################################
# Imports
##############################################################################
import os
import catkin_pkg.packages
import catkin_pkg.topological_order
##############################################################################
# Methods
##############################################################################
def has_build_depend_on_message_generation(package):
'''
Checks for a build dependency on message generation to determine if
that package contains msgs/srvs.
@param package : typical catkin package object
@type catkin_pkg.Package
@return True if it is a package that contains msgs/srvs
@rtype Bool
'''
return 'message_generation' in [d.name for d in package.build_depends]
def index_message_package_dependencies_from_local_environment(package_name=None, package_paths=None):
'''
Returns a topologically sorted list of message packages that can
be used for sequencing builds of packages.
@param package_name : sort dependencies for this package only (defaults to all packages if None is given)
@param package_paths : a python list of ros workspaces (defaults to ROS_PACKAGE_PATH if None is given)
@return dict mapping relative path to a catkin_pkg.Package
'''
if package_paths is None:
package_paths = os.getenv('ROS_PACKAGE_PATH', '')
package_paths = [x for x in package_paths.split(':') if x]
all_packages = {} # mapping package name to (path, catkin_pkg.Package) tuple
message_packages = {}
# use reversed to write over any packages lower down in the overlay heirarchy
# i.e. no duplicates!
for path in reversed(package_paths):
for package_path, package in catkin_pkg.packages.find_packages(path).items():
all_packages[package.name] = (package_path, package)
if has_build_depend_on_message_generation(package):
if package_name is not None:
if package_name == package.name:
message_packages[package.name] = (package_path, package)
else:
message_packages[package.name] = (package_path, package)
# put into the correct form for sorting
# The following returns: A list of tuples containing the relative path and a ``Package`` object,
sorted_package_tuples = catkin_pkg.topological_order.topological_order_packages(
packages=dict(message_packages.values()),
whitelisted=None,
blacklisted=None,
underlay_packages=dict(all_packages.values()))
# print("%s" % [p.name for (unused_relative_path, p) in sorted_package_tuples])
return sorted_package_tuples
......@@ -6,26 +6,13 @@
import rosdistro
import catkin_pkg
from . import catkin
##############################################################################
# Imports
##############################################################################
def has_build_depend_on_message_generation(package):
'''
Checks for a build dependency on message generation to determine if
that package contains msgs/srvs.
@param package : typical catkin package object
@type catkin_pkg.Package
@return True if it is a package that contains msgs/srvs
@rtype Bool
'''
return 'message_generation' in [d.name for d in package.build_depends]
def scrape_for_release_message_packages(track):
url = rosdistro.get_index_url()
index = rosdistro.get_index(url)
......@@ -35,6 +22,6 @@ def scrape_for_release_message_packages(track):
package = catkin_pkg.package.parse_package_string(package_string)
#print(" Name: %s" % package_name)
#print(" Buildtool Depends %s" % package.build)
if has_build_depend_on_message_generation(package):
if catkin.has_build_depend_on_message_generation(package):
packages.append({'name': package_name, 'version': package.version})
return packages
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment