catkin.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 ##############################################################################
00004 # Imports
00005 ##############################################################################
00006 
00007 import os
00008 import catkin_pkg.packages
00009 import catkin_pkg.topological_order
00010 
00011 ##############################################################################
00012 # Constants
00013 ##############################################################################
00014 
00015 # packages that don't properly identify themselves as message packages (fix upstream).
00016 message_package_whitelist = ['map_store']
00017 
00018 ##############################################################################
00019 # Methods
00020 ##############################################################################
00021 
00022 
00023 def has_build_depend_on_message_generation(package):
00024     '''
00025       Checks for a build dependency on message generation to determine if
00026       that package contains msgs/srvs.
00027 
00028       @param package : typical catkin package object
00029       @type catkin_pkg.Package
00030 
00031       @return True if it is a package that contains msgs/srvs
00032       @rtype Bool
00033     '''
00034     return 'message_generation' in [d.name for d in package.build_depends]
00035 
00036 
00037 def index_message_package_dependencies_from_local_environment(package_name_list=[], package_paths=None):
00038     '''
00039       Returns a topologically sorted list of message packages that can
00040       be used for sequencing builds of packages.
00041 
00042       @param package_name_list : sort dependencies for these packages only (defaults to all if empty)
00043       @param package_paths : a python list of ros workspaces (defaults to ROS_PACKAGE_PATH if None is given)
00044       @return dict mapping relative path to a catkin_pkg.Package
00045     '''
00046     if package_paths is None:
00047         package_paths = os.getenv('ROS_PACKAGE_PATH', '')
00048         package_paths = [x for x in package_paths.split(':') if x]
00049     all_packages = {}  # mapping package name to (path, catkin_pkg.Package) tuple
00050     message_packages = {}
00051     # use reversed to write over any packages lower down in the overlay heirarchy
00052     # i.e. no duplicates!
00053     for path in reversed(package_paths):
00054         for package_path, package in catkin_pkg.packages.find_packages(path).items():
00055             all_packages[package.name] = (package_path, package)
00056             if has_build_depend_on_message_generation(package) or package.name in message_package_whitelist:
00057                 if package_name_list:
00058                     if package.name in package_name_list:
00059                         message_packages[package.name] = (package_path, package)
00060                 else:
00061                     message_packages[package.name] = (package_path, package)
00062     # put into the correct form for sorting
00063     # The following returns: A list of tuples containing the relative path and a ``Package`` object,
00064     sorted_package_tuples = catkin_pkg.topological_order.topological_order_packages(
00065                                 packages=dict(message_packages.values()),
00066                                 whitelisted=None,
00067                                 blacklisted=None,
00068                                 underlay_packages=dict(all_packages.values()))
00069     # print("%s" % [p.name for (unused_relative_path, p) in sorted_package_tuples])
00070     return sorted_package_tuples


rosjava_build_tools
Author(s): Daniel Stonier
autogenerated on Sat Jun 8 2019 19:54:56