Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions colcon_cargo/package_discovery/cargo_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def discover(self, *, args, identification_extensions): # noqa: D102
for extension in extensions_same_prio.values():
if isinstance(extension, CargoWorkspaceIdentification):
paths.update(extension.workspace_package_paths)
paths.update(extension.non_cargo_paths)
extension.workspace_package_paths.clear()

descs = set()
Expand Down
20 changes: 18 additions & 2 deletions colcon_cargo/package_identification/cargo_workspace.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright 2025 Open Source Robotics Foundation, Inc.
# Licensed under the Apache License, Version 2.0

import pathlib

from colcon_cargo.package_identification.cargo import read_cargo_toml
from colcon_core.package_identification import IgnoreLocationException
from colcon_core.package_identification \
Expand All @@ -25,6 +27,7 @@ def __init__(self): # noqa: D107
PackageIdentificationExtensionPoint.EXTENSION_POINT_VERSION,
'^1.0')
self.workspace_package_paths = set()
self.non_cargo_paths = set()

def identify(self, metadata): # noqa: D102
if metadata.type is not None and metadata.type != 'cargo':
Expand All @@ -43,13 +46,26 @@ def identify(self, metadata): # noqa: D102
for pattern in content['workspace'].get('members', ())
for member in metadata.path.glob(pattern)
}
ws_members.difference_update(
excluded_ws_members = {
exclude
for pattern in content['workspace'].get('exclude', ())
for exclude in metadata.path.glob(pattern)
)
}
ws_members.difference_update(excluded_ws_members)
self.workspace_package_paths.update(ws_members)

all_package_paths = {
p.parent
for p in pathlib.Path(metadata.path).rglob('package.xml')
if not pathlib.Path(p.parent / 'Cargo.toml').is_file()
}

self.non_cargo_paths.update(
all_package_paths.difference(
self.workspace_package_paths, excluded_ws_members
)
)

if 'package' not in content:
# Prevent any further attempts to discover packages in this
# directory and let the workspace dictate where to look for
Expand Down
Loading