@@ -2628,7 +2628,7 @@ def _import_path_from_project(self, project: Project, path: str) -> None:
26282628 return
26292629
26302630 for data in imported :
2631- self ._import_data_from_project (project , data , None )
2631+ self ._import_data_from_project (project , data , None , path )
26322632
26332633 _logger .debug (f'done resolving import { path } for { project } ' )
26342634
@@ -2642,12 +2642,13 @@ def _import_map_from_project(self, project: Project, imp: dict) -> None:
26422642 return
26432643
26442644 for data in imported :
2645- self ._import_data_from_project (project , data , imap )
2645+ self ._import_data_from_project (project , data , imap , imap . file )
26462646
26472647 _logger .debug (f'done resolving import { imap } for { project } ' )
26482648
26492649 def _import_data_from_project (
2650- self , project : Project , data : Any , imap : _import_map | None
2650+ self , project : Project , data : Any ,
2651+ imap : _import_map | None , manifest_path : str | None = None
26512652 ) -> None :
26522653 # Destructively add the imported data into our 'projects' map.
26532654
@@ -2678,8 +2679,22 @@ def _import_data_from_project(
26782679
26792680 # Patch up any extension commands in the imported data
26802681 # by allocating them to the project.
2682+
2683+ # If the manifest was imported from a project subdirectory
2684+ # (manifest_path is a relative path within the project),
2685+ # we need to adjust the west_commands paths to be relative
2686+ # to the project root, not to the manifest subdirectory.
2687+ west_commands_to_merge = submanifest ._ctx .manifest_west_commands
2688+ if manifest_path and manifest_path != _WEST_YML :
2689+ manifest_dir = os .path .dirname (manifest_path )
2690+ if manifest_dir :
2691+ west_commands_to_merge = [
2692+ os .path .join (manifest_dir , cmd ).replace ('\\ ' , '/' )
2693+ for cmd in west_commands_to_merge
2694+ ]
2695+
26812696 project .west_commands = _west_commands_merge (
2682- project .west_commands , submanifest . _ctx . manifest_west_commands
2697+ project .west_commands , west_commands_to_merge
26832698 )
26842699
26852700 def _import_content_from_project (self , project : Project , path : str ) -> ImportedContentType :
0 commit comments