Skip to content

Commit 86ae247

Browse files
committed
fix: discover non Cargo packages in a Cargo workspace
Signed-off-by: Esteve Fernandez <esteve@apache.org>
1 parent ec2b28b commit 86ae247

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

colcon_cargo/package_discovery/cargo_workspace.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def discover(self, *, args, identification_extensions): # noqa: D102
3535
for extension in extensions_same_prio.values():
3636
if isinstance(extension, CargoWorkspaceIdentification):
3737
paths.update(extension.workspace_package_paths)
38+
paths.update(extension.non_cargo_paths)
3839
extension.workspace_package_paths.clear()
3940

4041
descs = set()

colcon_cargo/package_identification/cargo_workspace.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright 2025 Open Source Robotics Foundation, Inc.
22
# Licensed under the Apache License, Version 2.0
33

4+
import pathlib
45
from colcon_cargo.package_identification.cargo import read_cargo_toml
56
from colcon_core.package_identification import IgnoreLocationException
67
from colcon_core.package_identification \
@@ -25,6 +26,7 @@ def __init__(self): # noqa: D107
2526
PackageIdentificationExtensionPoint.EXTENSION_POINT_VERSION,
2627
'^1.0')
2728
self.workspace_package_paths = set()
29+
self.non_cargo_paths = set()
2830

2931
def identify(self, metadata): # noqa: D102
3032
if metadata.type is not None and metadata.type != 'cargo':
@@ -43,13 +45,24 @@ def identify(self, metadata): # noqa: D102
4345
for pattern in content['workspace'].get('members', ())
4446
for member in metadata.path.glob(pattern)
4547
}
46-
ws_members.difference_update(
48+
excluded_ws_members = {
4749
exclude
4850
for pattern in content['workspace'].get('exclude', ())
4951
for exclude in metadata.path.glob(pattern)
50-
)
52+
}
53+
ws_members.difference_update(excluded_ws_members)
5154
self.workspace_package_paths.update(ws_members)
5255

56+
all_package_paths = {
57+
p.parent for p in pathlib.Path(metadata.path).rglob("package.xml")
58+
}
59+
60+
self.non_cargo_paths.update(
61+
all_package_paths.difference(
62+
self.workspace_package_paths, excluded_ws_members
63+
)
64+
)
65+
5366
if 'package' not in content:
5467
# Prevent any further attempts to discover packages in this
5568
# directory and let the workspace dictate where to look for

0 commit comments

Comments
 (0)