From b3fa65679257771d8c29f7fbd71fa66653020672 Mon Sep 17 00:00:00 2001 From: Mike Malburg Date: Fri, 13 Oct 2023 14:55:06 -0400 Subject: [PATCH] Fix Remove-DylibSmlinks The opencv4 lib main dylibs have underscores and dashes in them, so include those as valid chars for the base lib filename. Also renamed some vars. --- ps-modules/MacBuild/MacBuild.psm1 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ps-modules/MacBuild/MacBuild.psm1 b/ps-modules/MacBuild/MacBuild.psm1 index 6e5ea920..60d5932d 100644 --- a/ps-modules/MacBuild/MacBuild.psm1 +++ b/ps-modules/MacBuild/MacBuild.psm1 @@ -158,16 +158,17 @@ function Remove-DylibSymlinks { Debug-WriteLibraryDependencies $mainFiles + $baseFilenameStartPattern = '[^a-zA-Z0-9-_]' foreach ($mainFile in $mainFiles) { # Main file Invoke-Expression "install_name_tool -id '@rpath/$mainFile' '$mainFile'" # All other files that might point to it - foreach ($possible_current_dependency in $filesWithVersions) { - $base_filename = ($possible_current_dependency -split '[^a-zA-Z0-9]')[0] # Discard anything after the first non-alphanumeric character - $new_dependency = "$base_filename.dylib" - if ($mainFiles -contains $new_dependency) { - Invoke-Expression "install_name_tool -change '@rpath/$possible_current_dependency' '@rpath/$new_dependency' '$mainFile'" + foreach ($possibleDependency in $filesWithVersions) { + $baseFilename = ($possibleDependency -split $baseFilenameStartPattern)[0] + $newDependency = "$baseFilename.dylib" + if ($mainFiles -contains $newDependency) { + Invoke-Expression "install_name_tool -change '@rpath/$possibleDependency' '@rpath/$newDependency' '$mainFile'" } } } @@ -185,8 +186,8 @@ function Remove-DylibSymlinks { $files = Get-ChildItem -File -Recurse foreach ($file in $files) { $oldFilename = $file.Name - $base_filename = ($oldFilename -split '[^a-zA-Z0-9]')[0] # Discard anything after the first non-alphanumeric character - $newFilename = "$base_filename" + [System.IO.Path]::GetExtension($file) + $baseFilename = ($oldFilename -split $baseFilenameStartPattern)[0] + $newFilename = "$baseFilename" + [System.IO.Path]::GetExtension($file) Move-Item -Path $file.Name -Destination $newFilename }