11# Copyright 2025 Open Source Robotics Foundation, Inc.
22# Licensed under the Apache License, Version 2.0
33
4+ import pathlib
5+
46from colcon_cargo .package_identification .cargo import read_cargo_toml
57from colcon_core .package_identification import IgnoreLocationException
68from 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