Skip to content

Commit

Permalink
Omit runtime dependencies from build ordering
Browse files Browse the repository at this point in the history
This change will allow a package which has only a runtime dependency on
another package to be built independently. It will not affect the
dependency-based package selection behavior, but could make the build
graph a little more shallow.
  • Loading branch information
cottsay committed Aug 3, 2023
1 parent 7b70e61 commit e2a8b22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 9 additions & 5 deletions colcon_core/package_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,20 @@ def get_dependencies(self, *, categories=None):
:raises AssertionError: if the package name is listed as a dependency
"""
dependencies = set()
categories_by_dependency = defaultdict(list)
if categories is None:
categories = self.dependencies.keys()
for category in sorted(categories):
dependencies |= self.dependencies[category]
for dependency in self.dependencies[category]:
categories_by_dependency[dependency].append(category)
for dependency, categories in categories_by_dependency.items():
if not isinstance(dependency, DependencyDescriptor):
dependency = DependencyDescriptor(dependency)
dependency.metadata['categories'] = categories
dependencies.add(dependency)
assert self.name not in dependencies, \
f"The package '{self.name}' has a dependency with the same name"
return {
(DependencyDescriptor(d)
if not isinstance(d, DependencyDescriptor) else d)
for d in dependencies}
return dependencies

def get_recursive_dependencies(
self, descriptors, direct_categories=None, recursive_categories=None,
Expand Down
3 changes: 3 additions & 0 deletions colcon_core/verb/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ def _get_jobs(self, args, decorators, install_base):

recursive_dependencies = OrderedDict()
for dep_name in decorator.recursive_dependencies:
if dep_name.metadata.get('depth') == 1:
if dep_name.metadata.get('categories') == ['run']:
continue

Check warning on line 187 in colcon_core/verb/build.py

View check run for this annotation

Codecov / codecov/patch

colcon_core/verb/build.py#L187

Added line #L187 was not covered by tests
dep_path = install_base
if not args.merge_install:
dep_path = os.path.join(dep_path, dep_name)
Expand Down

0 comments on commit e2a8b22

Please sign in to comment.