Skip to content

Commit 2f4d85e

Browse files
committed
support for a message artifact command line generator.
1 parent 65d5c22 commit 2f4d85e

File tree

3 files changed

+66
-15
lines changed

3 files changed

+66
-15
lines changed

src/rosjava_build_tools/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
from create_rosjava_project import create_rosjava_project, create_rosjava_msg_project, create_rosjava_library_project
1111
from utils import which
1212
from release import scrape_for_release_message_packages
13+
import catkin

src/rosjava_build_tools/catkin.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env python
2+
3+
##############################################################################
4+
# Imports
5+
##############################################################################
6+
7+
import os
8+
import catkin_pkg.packages
9+
import catkin_pkg.topological_order
10+
11+
##############################################################################
12+
# Methods
13+
##############################################################################
14+
15+
16+
def has_build_depend_on_message_generation(package):
17+
'''
18+
Checks for a build dependency on message generation to determine if
19+
that package contains msgs/srvs.
20+
21+
@param package : typical catkin package object
22+
@type catkin_pkg.Package
23+
24+
@return True if it is a package that contains msgs/srvs
25+
@rtype Bool
26+
'''
27+
return 'message_generation' in [d.name for d in package.build_depends]
28+
29+
30+
def index_message_package_dependencies_from_local_environment(package_name=None, package_paths=None):
31+
'''
32+
Returns a topologically sorted list of message packages that can
33+
be used for sequencing builds of packages.
34+
35+
@param package_name : sort dependencies for this package only (defaults to all packages if None is given)
36+
@param package_paths : a python list of ros workspaces (defaults to ROS_PACKAGE_PATH if None is given)
37+
@return dict mapping relative path to a catkin_pkg.Package
38+
'''
39+
if package_paths is None:
40+
package_paths = os.getenv('ROS_PACKAGE_PATH', '')
41+
package_paths = [x for x in package_paths.split(':') if x]
42+
all_packages = {} # mapping package name to (path, catkin_pkg.Package) tuple
43+
message_packages = {}
44+
# use reversed to write over any packages lower down in the overlay heirarchy
45+
# i.e. no duplicates!
46+
for path in reversed(package_paths):
47+
for package_path, package in catkin_pkg.packages.find_packages(path).items():
48+
all_packages[package.name] = (package_path, package)
49+
if has_build_depend_on_message_generation(package):
50+
if package_name is not None:
51+
if package_name == package.name:
52+
message_packages[package.name] = (package_path, package)
53+
else:
54+
message_packages[package.name] = (package_path, package)
55+
# put into the correct form for sorting
56+
# The following returns: A list of tuples containing the relative path and a ``Package`` object,
57+
sorted_package_tuples = catkin_pkg.topological_order.topological_order_packages(
58+
packages=dict(message_packages.values()),
59+
whitelisted=None,
60+
blacklisted=None,
61+
underlay_packages=dict(all_packages.values()))
62+
# print("%s" % [p.name for (unused_relative_path, p) in sorted_package_tuples])
63+
return sorted_package_tuples

src/rosjava_build_tools/release.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,13 @@
66

77
import rosdistro
88
import catkin_pkg
9+
from . import catkin
910

1011
##############################################################################
1112
# Imports
1213
##############################################################################
1314

1415

15-
def has_build_depend_on_message_generation(package):
16-
'''
17-
Checks for a build dependency on message generation to determine if
18-
that package contains msgs/srvs.
19-
20-
@param package : typical catkin package object
21-
@type catkin_pkg.Package
22-
23-
@return True if it is a package that contains msgs/srvs
24-
@rtype Bool
25-
'''
26-
return 'message_generation' in [d.name for d in package.build_depends]
27-
28-
2916
def scrape_for_release_message_packages(track):
3017
url = rosdistro.get_index_url()
3118
index = rosdistro.get_index(url)
@@ -35,6 +22,6 @@ def scrape_for_release_message_packages(track):
3522
package = catkin_pkg.package.parse_package_string(package_string)
3623
#print(" Name: %s" % package_name)
3724
#print(" Buildtool Depends %s" % package.build)
38-
if has_build_depend_on_message_generation(package):
25+
if catkin.has_build_depend_on_message_generation(package):
3926
packages.append({'name': package_name, 'version': package.version})
4027
return packages

0 commit comments

Comments
 (0)