Skip to content

Commit f334adc

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

2 files changed

Lines changed: 17 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: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright 2025 Open Source Robotics Foundation, Inc.
22
# Licensed under the Apache License, Version 2.0
33

4+
import pathlib
5+
46
from colcon_cargo.package_identification.cargo import read_cargo_toml
57
from colcon_core.package_identification import IgnoreLocationException
68
from colcon_core.package_identification \
@@ -25,6 +27,7 @@ def __init__(self): # noqa: D107
2527
PackageIdentificationExtensionPoint.EXTENSION_POINT_VERSION,
2628
'^1.0')
2729
self.workspace_package_paths = set()
30+
self.non_cargo_paths = set()
2831

2932
def identify(self, metadata): # noqa: D102
3033
if metadata.type is not None and metadata.type != 'cargo':
@@ -43,13 +46,24 @@ def identify(self, metadata): # noqa: D102
4346
for pattern in content['workspace'].get('members', ())
4447
for member in metadata.path.glob(pattern)
4548
}
46-
ws_members.difference_update(
49+
excluded_ws_members = {
4750
exclude
4851
for pattern in content['workspace'].get('exclude', ())
4952
for exclude in metadata.path.glob(pattern)
50-
)
53+
}
54+
ws_members.difference_update(excluded_ws_members)
5155
self.workspace_package_paths.update(ws_members)
5256

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

0 commit comments

Comments
 (0)