@@ -926,19 +926,26 @@ def build_platforms():
926926 symlinks = True , ignore_dangling_symlinks = True , dirs_exist_ok = True )
927927
928928
929- def install_lib (sof_lib_dir , abs_build_dir , platform_wconfig ):
929+ def install_lib (platform , sof_output_dir , abs_build_dir , platform_wconfig ):
930930 """[summary] Sign loadable llext modules, if any, copy them to the
931931 deployment tree and create UUID links for the kernel to find and load
932932 them."""
933933
934934 global signing_key
935935
936- with os .scandir (str (abs_build_dir )) as iter :
937- if args .key_type_subdir != "none" :
938- sof_lib_dir = sof_lib_dir / args .key_type_subdir
936+ libs = dict ()
937+ lib_uuids = dict ()
938+ rimage_cmd = shlex .split (platform_wconfig .get ('rimage.path' ))[0 ]
939+ _ws_args = platform_wconfig .get ("rimage.extra-args" )
940+
941+ sof_lib_dir = sof_output_dir / '..' / 'sof-ipc4-lib' / platform
939942
940- sof_lib_dir .mkdir (parents = True , exist_ok = True )
943+ if args .key_type_subdir != "none" :
944+ sof_lib_dir = sof_lib_dir / args .key_type_subdir
945+
946+ sof_lib_dir .mkdir (parents = True , exist_ok = True )
941947
948+ with os .scandir (str (abs_build_dir )) as iter :
942949 for entry in iter :
943950 if (not entry .is_dir or
944951 not entry .name .endswith ('_llext' )):
@@ -955,45 +962,87 @@ def install_lib(sof_lib_dir, abs_build_dir, platform_wconfig):
955962 # eq_iir_llext/eq_iir.llext
956963 llext_base = entry .name [:- 6 ]
957964 llext_file = llext_base + '.llext'
958-
959- dst = sof_lib_dir / llext_file
960-
961- rimage_cfg = entry_path / 'rimage_config.toml'
962- llext_input = entry_path / (llext_base + '.llext' )
963- llext_output = entry_path / (llext_file + '.ri' )
964-
965- # See why the shlex() parsing step is required at
966- # https://docs.zephyrproject.org/latest/develop/west/sign.html#rimage
967- # and in Zephyr commit 030b740bd1ec
968- rimage_cmd = shlex .split (platform_wconfig .get ('rimage.path' ))[0 ]
969- sign_cmd = [rimage_cmd , "-o" , str (llext_output ),
970- "-e" , "-c" , str (rimage_cfg ),
971- "-k" , str (signing_key ), "-l" , "-r" ]
972- _ws_args = platform_wconfig .get ("rimage.extra-args" )
973- if _ws_args is not None :
974- sign_cmd .extend (shlex .split (_ws_args ))
975- sign_cmd .append (str (llext_input ))
976- execute_command (sign_cmd , cwd = west_top )
977-
978- # An intuitive way to make this multiline would be
979- # with (open(dst, 'wb') as fdst, open(llext_output, 'rb') as fllext,
980- # open(llext_output.with_suffix('.llext.xman'), 'rb') as fman):
981- # but a Python version, used on Windows errored out on this.
982- # Thus we're left with a choice between a 150-character
983- # long line and an illogical split like this
984- with open (dst , 'wb' ) as fdst , open (llext_output , 'rb' ) as fllext , open (
985- llext_output .with_suffix ('.ri.xman' ), 'rb' ) as fman :
986- # Concatenate the manifest and the llext
987- shutil .copyfileobj (fman , fdst )
988- shutil .copyfileobj (fllext , fdst )
965+ lib_name = ''
966+
967+ lib_fname = entry_path / 'lib_name.txt'
968+ if os .path .exists (lib_fname ):
969+ with open (lib_fname , 'r' ) as libs_f :
970+ lib_name = libs_f .read ()
971+ if lib_name not in libs .keys ():
972+ libs [lib_name ] = []
973+ libs [lib_name ].append (str (entry_path / llext_file ))
974+ else :
975+ dst = sof_lib_dir / llext_file
976+
977+ rimage_cfg = entry_path / 'rimage_config.toml'
978+ llext_input = entry_path / (llext_base + '.llext' )
979+ llext_output = entry_path / (llext_file + '.ri' )
980+
981+ # See why the shlex() parsing step is required at
982+ # https://docs.zephyrproject.org/latest/develop/west/sign.html#rimage
983+ # and in Zephyr commit 030b740bd1ec
984+ sign_cmd = [rimage_cmd , "-o" , str (llext_output ),
985+ "-e" , "-c" , str (rimage_cfg ),
986+ "-k" , str (signing_key ), "-l" , "-r" ]
987+ if _ws_args is not None :
988+ sign_cmd .extend (shlex .split (_ws_args ))
989+ sign_cmd .append (str (llext_input ))
990+ execute_command (sign_cmd , cwd = west_top )
991+
992+ # An intuitive way to make this multiline would be
993+ # with (open(dst, 'wb') as fdst, open(llext_output, 'rb') as fllext,
994+ # open(llext_output.with_suffix('.llext.xman'), 'rb') as fman):
995+ # but a Python version, used on Windows errored out on this.
996+ # Thus we're left with a choice between a 150-character
997+ # long line and an illogical split like this
998+ with open (dst , 'wb' ) as fdst , open (llext_output , 'rb' ) as fllext , open (
999+ llext_output .with_suffix ('.ri.xman' ), 'rb' ) as fman :
1000+ # Concatenate the manifest and the llext
1001+ shutil .copyfileobj (fman , fdst )
1002+ shutil .copyfileobj (fllext , fdst )
9891003
9901004 # Create symbolic links for all UUIDs
9911005 with open (uuids , 'r' ) as uuids_f :
9921006 for uuid in uuids_f :
993- linkname = uuid .strip () + '.bin'
994- symlink_or_copy (sof_lib_dir , llext_file ,
995- sof_lib_dir , linkname )
1007+ if os .path .exists (lib_fname ):
1008+ if lib_name not in lib_uuids .keys ():
1009+ lib_uuids [lib_name ] = []
1010+ lib_uuids [lib_name ].append (uuid .strip ())
1011+ else :
1012+ linkname = uuid .strip () + '.bin'
1013+ symlink_or_copy (sof_lib_dir , llext_file ,
1014+ sof_lib_dir , linkname )
1015+
1016+ lib_install_dir = sof_output_dir / platform
1017+ if args .key_type_subdir != "none" :
1018+ lib_install_dir = lib_install_dir / args .key_type_subdir
1019+
1020+ for key in libs .keys ():
1021+ lib_path = abs_build_dir / '' .join (['lib' , key , '.ri' ])
1022+ sign_cmd = [rimage_cmd , "-o" , str (lib_path ), "-e" ,
1023+ "-c" , str (abs_build_dir / 'misc' / 'generated' / 'rimage_config_full.toml' ),
1024+ "-k" , str (signing_key ), "-l" , "-r" ]
1025+ if _ws_args is not None :
1026+ sign_cmd .extend (shlex .split (_ws_args ))
1027+ sign_cmd .extend (libs [key ])
1028+ execute_command (sign_cmd , cwd = west_top )
1029+ lib_name = '' .join (['sof-' , platform , '-' , key , '.ri' ])
1030+ dst = lib_install_dir / lib_name
1031+ with open (dst , 'wb' ) as fdst , open (lib_path , 'rb' ) as fllext , open (
1032+ lib_path .with_suffix ('.ri.xman' ), 'rb' ) as fman :
1033+ # Concatenate the manifest and the llext
1034+ shutil .copyfileobj (fman , fdst )
1035+ shutil .copyfileobj (fllext , fdst )
1036+
1037+ for p_alias in platform_configs [platform ].aliases :
1038+ lib_dir = sof_output_dir / p_alias
9961039
1040+ if args .key_type_subdir != "none" :
1041+ lib_dir = lib_dir / args .key_type_subdir
1042+ lib_dir .mkdir (parents = True , exist_ok = True )
1043+ alias_libname = '' .join (['sof-' , p_alias , '-' , key , '.ri' ])
1044+ symlink_or_copy (lib_install_dir , lib_name ,
1045+ lib_dir , alias_libname )
9971046
9981047def install_platform (platform , sof_output_dir , platf_build_environ , platform_wconfig ):
9991048
@@ -1042,8 +1091,7 @@ def install_platform(platform, sof_output_dir, platf_build_environ, platform_wco
10421091 symlink_or_copy (install_key_dir , output_fwname , install_key_dir , f"sof-{ p_alias } .ri" )
10431092
10441093 if args .deployable_build and platform_configs [platform ].ipc4 :
1045- install_lib (sof_output_dir / '..' / 'sof-ipc4-lib' / platform , abs_build_dir ,
1046- platform_wconfig )
1094+ install_lib (platform , sof_output_dir , abs_build_dir , platform_wconfig )
10471095
10481096
10491097 # sof-info/ directory
0 commit comments