@@ -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,12 @@ 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 , imap : _import_map | None , manifest_path : str | None = None
26512651 ) -> None :
26522652 # Destructively add the imported data into our 'projects' map.
26532653
@@ -2678,8 +2678,22 @@ def _import_data_from_project(
26782678
26792679 # Patch up any extension commands in the imported data
26802680 # by allocating them to the project.
2681+
2682+ # If the manifest was imported from a project subdirectory
2683+ # (manifest_path is a relative path within the project),
2684+ # we need to adjust the west_commands paths to be relative
2685+ # to the project root, not to the manifest subdirectory.
2686+ west_commands_to_merge = submanifest ._ctx .manifest_west_commands
2687+ if manifest_path and manifest_path != _WEST_YML :
2688+ manifest_dir = os .path .dirname (manifest_path )
2689+ if manifest_dir :
2690+ west_commands_to_merge = [
2691+ os .path .join (manifest_dir , cmd ).replace ('\\ ' , '/' )
2692+ for cmd in west_commands_to_merge
2693+ ]
2694+
26812695 project .west_commands = _west_commands_merge (
2682- project .west_commands , submanifest . _ctx . manifest_west_commands
2696+ project .west_commands , west_commands_to_merge
26832697 )
26842698
26852699 def _import_content_from_project (self , project : Project , path : str ) -> ImportedContentType :
0 commit comments