Skip to content

Commit

Permalink
Test: migrate from ldd-apple to otool
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed May 26, 2024
1 parent 5b18367 commit 75de633
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@
[submodule "tdsharp"]
path = tdsharp
url = https://github.com/egramtel/tdsharp.git
[submodule "ldd-apple"]
path = ldd-apple
url = https://github.com/tetractius/ldd-apple.git
1 change: 0 additions & 1 deletion ldd-apple
Submodule ldd-apple deleted from 6de253
21 changes: 5 additions & 16 deletions macos/Test-Dependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ param (
[string] $Package = "$RepoRoot/build/$PackageName/runtimes/osx-$DotNetArch/native",
[string] $GoldFile = "$RepoRoot/macos/libraries.$DotNetArch.gold.txt",
[string] $ResultFile = "$RepoRoot/macos/libraries.temp.txt",
[string] $LddApple = "$RepoRoot/ldd-apple/ldd-apple.sh",
[switch] $GenerateGold
)

Expand All @@ -24,26 +23,16 @@ Get-ChildItem "$Package/*.dylib" | Sort-Object -Property Name | ForEach-Object {
$libraryPath = $_.FullName

Write-Output "Checking file `"$libraryPath`""
$output = & $LddApple $libraryPath *>&1
$output = otool -L $libraryPath
if (!$?) {
throw "ldd-apple returned an exit code $LASTEXITCODE."
throw "otool returned an exit code $LASTEXITCODE."
}

Write-Output "Output from ldd-apple $($libraryPath):"
Write-Output "Output from otool -L $($libraryPath):"
Write-Output $output

$libraryNames = $output | Where-Object {
[string]$line = $_
$line.StartsWith('dyld[') -or $line.StartsWith('dyld: loaded:')
} | ForEach-Object {
if (!($_ -match 'dyld(?:: loaded|\[\d+\]): <.*?> (.*)')) {
throw "Failed to parse ldd-apple output: $_"
}

$filePath = $Matches[1]
if ($filePath -ne $libraryPath -and !$filePath.Contains('cpp.exec')) {
$filePath
}
$libraryNames = $output | Where-Object { $_.StartsWith(' ') } | ForEach-Object {
$_.Trim()
} | Sort-Object
$_.Name >> $ResultFile
$libraryNames | ForEach-Object { " $_" >> $ResultFile }
Expand Down

0 comments on commit 75de633

Please sign in to comment.