Skip to content

Commit

Permalink
Fix Remove-DylibSmlinks
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mike-malburg committed Oct 13, 2023
1 parent bb09daf commit b3fa656
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions ps-modules/MacBuild/MacBuild.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
}
}
}
Expand All @@ -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
}

Expand Down

0 comments on commit b3fa656

Please sign in to comment.