@@ -438,7 +438,11 @@ def rimage_config_dir(self):
438438 def generate_uuid_registry (self ):
439439 'Runs the uuid-registry.h generator script'
440440
441- generate_cmd = [sys .executable , str (self .sof_src_dir / 'scripts' / 'gen-uuid-reg.py' ),
441+ uuid_script_path = self .sof_src_dir / 'scripts' / 'gen-uuid-reg.py'
442+ if not uuid_script_path .exists ():
443+ self .command .die (f"{ uuid_script_path } does not exists." )
444+
445+ generate_cmd = [sys .executable , str (uuid_script_path ),
442446 str (self .sof_src_dir / 'uuid-registry.txt' ),
443447 str (pathlib .Path ('zephyr' ) / 'include' / 'generated' / 'uuid-registry.h' )
444448 ]
@@ -554,13 +558,56 @@ def sign(self, command, build_dir, build_conf, formats):
554558 if not args .quiet :
555559 command .inf ('Signing with tool {}' .format (tool_path ))
556560
557- try :
558- sof_proj = command .manifest .get_projects (['sof' ], allow_paths = False )
559- sof_src_dir = pathlib .Path (sof_proj [0 ].abspath )
560- except ValueError : # sof is the manifest
561- sof_src_dir = pathlib .Path (manifest .manifest_path ()).parent
561+ sof_src_dir = None
562+
563+ # Try to find SOF directory via path to rimage config files
564+ conf_dir = self .cmake_cache .get ('RIMAGE_CONFIG_PATH' )
565+ if conf_dir :
566+ # Config path is <sof top>/tools/rimage/config/
567+ # So need to go up 3 levels to get SOF directory.
568+ maybe_sof_dir = pathlib .Path (conf_dir ).parent .parent .parent
569+
570+ # Make sure this is the actual SOF directory as
571+ # RIMAGE_CONFIG_PATH may point to somewhere else.
572+ versions_json_file = maybe_sof_dir / 'versions.json'
573+ if versions_json_file .exists ():
574+ sof_src_dir = maybe_sof_dir
575+
576+ # Try to find SOF if it is included via manifest
577+ if not sof_src_dir :
578+ try :
579+ sof_proj = command .manifest .get_projects (['sof' ], allow_paths = False )
580+ sof_src_dir = pathlib .Path (sof_proj [0 ].abspath )
581+
582+ # Since SOF is pulled in as a project, we assume it is
583+ # the correct one as the manifest has to be modified
584+ # manually.
585+ except ValueError :
586+ pass
587+
588+ # If SOF is the top level manifest via west init
589+ if not sof_src_dir :
590+ maybe_sof_dir = pathlib .Path (manifest .manifest_path ()).parent
591+
592+ # Make sure this is the actual SOF directory
593+ # as the top level manifest may not be SOF.
594+ versions_json_file = maybe_sof_dir / 'versions.json'
595+ if versions_json_file .exists ():
596+ sof_src_dir = maybe_sof_dir
597+
598+ # If it is specified via environment variable
599+ if not sof_src_dir and os .getenv ("SOF_SRC_DIR" ):
600+ maybe_sof_dir = pathlib .Path (os .getenv ("SOF_SRC_DIR" ))
601+
602+ # Make sure this is the actual SOF directory
603+ # as the top level manifest may not be SOF.
604+ versions_json_file = maybe_sof_dir / 'versions.json'
605+ if versions_json_file .exists ():
606+ sof_src_dir = maybe_sof_dir
562607
563608 self .sof_src_dir = sof_src_dir
609+ if not self .sof_src_dir :
610+ command .die ("Cannot find SOF directory." )
564611
565612
566613 command .inf ('Signing for SOC target ' + target )
0 commit comments