@@ -165,15 +165,42 @@ def copyLibraryAndSymbolPackage(src_file, dest_folder, overwrite):
165165#
166166#
167167#
168- def getFilenameWithoutVersion ( file_name ) -> str :
168+ def getFileBaseNameWithoutVersion ( file_path ) -> str :
169169 """
170- :return: `'libSDL2 '` for something like `'libSDL2-2.0.0 .dylib'`
170+ :return: `'libpostproc '` for something like `'/foo/bar/libpostproc.55.9.100 .dylib'`
171171 """
172- result = file_name .split ('.' )[0 ]
172+ base_name = os .path .basename (file_path )
173+ base_name = base_name .split ('.' )[0 ] # keep everything before first '.'
173174 # libSDL2 weirdly has hypthen after then name (i.e., libSDL2-2.0.0.dylib)
174- if 'libSDL2' in result :
175- result = 'libSDL2'
176- return result
175+ if base_name .startswith ('libSDL2' ):
176+ base_name = 'libSDL2'
177+ return base_name
178+
179+ #
180+ #
181+ #
182+ def getVersionVariantsForFile (file_path ) -> list [str ]:
183+ """
184+ Returns the following three files for any one of the file paths provided:
185+ `'.../ffmpeg-build-script/workspace/lib/libavcodec.58.134.100.dylib'`
186+ `'.../ffmpeg-build-script/workspace/lib/libavcodec.58.dylib'`
187+ `'.../ffmpeg-build-script/workspace/lib/libavcodec.dylib'`
188+
189+ """
190+ result = set ()
191+ result .add (file_path )
192+ if (pathlib .Path (file_path ).is_symlink ()):
193+ result .add (os .path .realpath (file_path ))
194+
195+ dependency_name_without_version = getFileBaseNameWithoutVersion (file_path )
196+ unversioned_dependency_base_name = os .path .join (
197+ os .path .dirname (file_path ),
198+ dependency_name_without_version )
199+
200+ for variant in glob .glob (unversioned_dependency_base_name + r'.*dylib' ):
201+ result .add (variant )
202+
203+ return list (result )
177204
178205#
179206#
@@ -206,8 +233,9 @@ def copyLibraryAndDependencies(src_file, dest_folder, log_file):
206233 src_dependency_file = match [0 ]
207234
208235 # fix incorrect usage of @rpath
209- if src_dependency_file .startswith ('@rpath/' ):
210- fixed_path = os .path .join (workspace_lib_dir , src_dependency_file [7 :])
236+ rpath_token = '@rpath/'
237+ if src_dependency_file .startswith (rpath_token ):
238+ fixed_path = os .path .join (workspace_lib_dir , src_dependency_file [len (rpath_token ):])
211239 loader_paths_to_rewrite .append ({'old_path' : src_dependency_file , 'new_path' : fixed_path })
212240 src_dependency_file = fixed_path
213241
@@ -224,17 +252,14 @@ def copyLibraryAndDependencies(src_file, dest_folder, log_file):
224252 if not src_dependency_file in copied_libs :
225253 if src_dependency_file != dest_dependency_path :
226254 # Copy each version variant file (often symlinks)
227- dependency_name_without_version = getFilenameWithoutVersion (src_dependency_file )
228- unversioned_dependency_base_name = os .path .join (os .path .dirname (src_dependency_file ), dependency_name_without_version )
229- for variant_src_file in glob .glob (unversioned_dependency_base_name + r'*.dylib' ):
255+ for variant_src_file in getVersionVariantsForFile (src_dependency_file ):
230256 copyLibraryAndSymbolPackage (variant_src_file , dest_folder , False )
231257 variant_dest_file = os .path .join (dest_folder , os .path .basename (variant_src_file ))
232258 copied_libs .add (variant_src_file )
233259 copied_libs .add (variant_dest_file )
234260
235261 # RECURSIVELY copy dependencies
236- if (os .path .exists (unversioned_dependency_base_name + '.dylib' )):
237- copyLibraryAndDependencies (unversioned_dependency_base_name + '.dylib' , dest_folder , log_file )
262+ copyLibraryAndDependencies (os .path .relpath (src_dependency_file ), dest_folder , log_file )
238263
239264 loader_paths_to_rewrite .append ({'old_path' : src_dependency_file , 'new_path' : dest_dependency_path })
240265 else :
@@ -342,17 +367,14 @@ def main():
342367 build_ffmpeg_log_file .write ('\n Generating Symbols\n ' )
343368 build_ffmpeg_log_file .write ('=======================\n ' )
344369 copyOrGenerateSymbolFiles (packages_dir , symbol_temp_dir , build_ffmpeg_log_file )
345- symbol_file_name = base_artifact_name + '-symbols'
346- shutil .make_archive (os .path .join (output_dir , symbol_file_name ), 'zip' , symbol_temp_dir )
347- shutil .rmtree (symbol_temp_dir )
348370
349371 # Generate dSYM files for each executable
350372 # and copy their dependencies
351373 for executable in executables :
352374 build_ffmpeg_log_file .write ('\n Copying & Linking ' + executable + '\n ' )
353375 build_ffmpeg_log_file .write ('=======================\n ' )
354376 executable_path = os .path .join (workspace_bin_dir , executable )
355- copyOrGenerateSymbolFile (executable_path , workspace_bin_dir , build_ffmpeg_log_file )
377+ copyOrGenerateSymbolFile (executable_path , symbol_temp_dir , build_ffmpeg_log_file )
356378 copyLibraryAndDependencies (executable_path , temp_dir , build_ffmpeg_log_file )
357379
358380 # check that the copied file is runnable
@@ -363,6 +385,10 @@ def main():
363385 output = subprocess .check_output (args )
364386 build_ffmpeg_log_file .write (output .decode ('utf-8' ))
365387
388+ symbol_file_name = base_artifact_name + '-symbols'
389+ shutil .make_archive (os .path .join (output_dir , symbol_file_name ), 'zip' , symbol_temp_dir )
390+ shutil .rmtree (symbol_temp_dir )
391+
366392 # Copy Includes
367393 shutil .copytree (
368394 os .path .join (workspace_dir , 'include' ),
0 commit comments