Skip to content

Commit

Permalink
Hotfix: Windows runtime deps in Azure (#145)
Browse files Browse the repository at this point in the history
* Recover dry run for LDD

* Adjust DLL list to restore
  • Loading branch information
MaxRev-Dev authored Aug 14, 2024
1 parent 8c619b7 commit 9be67b6
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions win/partials.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -356,17 +356,22 @@ function Copy-DependentDLLs {
$dllProcessed = @{}
$targetDll = [System.IO.Path]::GetFileName($dllFileInternal)
Write-BuildStep "Copying dependent DLLs for $dllFileInternal"
Write-BuildInfo "DLL file unix: $dllFileUnix"
# Convert Windows paths to Unix paths for Git Bash and construct LD_LIBRARY_PATH
$ldLibraryPath = ($dllDirectories | ForEach-Object { Convert-ToUnixPath $_ }) -join ":"
# Use overridePath if provided, otherwise use an empty string
$combinedPath = if ($overridePath) { "${overridePath}:${ldLibraryPath}" } else { $ldLibraryPath }

$dllFileUnix = Convert-ToUnixPath $dllFile
Write-BuildInfo "DLL file unix: $dllFileUnix"

# Get the list of dependent DLLs using ldd
Write-BuildInfo "Dry run ldd command: "
& $env:GitBash -c "PATH=${combinedPath}:`$PATH ldd $dllFileUnix"

# Construct the LDD string
$bashCommand = if ($combinedPath) { "PATH=${combinedPath}:`$PATH ldd $dllFileUnix" } else { "ldd $dllFileUnix" }

$lddOutput = & 'C:\Program Files\Git\bin\bash.exe' -c "$bashCommand"
$lddOutput = & $env:GitBash -c "$bashCommand"

$lddLines = $lddOutput -split "`n"
$dllPaths = @()
Expand All @@ -387,11 +392,13 @@ function Copy-DependentDLLs {

$dllPath = $dllPath -replace "/", "\"

# Skip system paths and include msodbcsql17.dll
if ($dllPath -notmatch "^\\c\\Windows" -or $dllPath -contains "^msodbcsql17.dll") {
# Skip system paths and include msodbcsql17.dll and other specific DLLs
$dllsToRestore = ("msodbcsql17.dll", "OpenCL.dll")
if ($dllPath -notmatch "^\\c\\Windows" -or $dllsToRestore.Contains($dllName)) {
if ($dllPath -match "^\\([a-z])\\") {
$dllPath = $dllPath -replace "^\\([a-z])\\", { "$($matches[1].ToUpper()):\" }
}
Write-BuildInfo "Found candidate for copy: $dllPath"
$dllPaths += $dllPath
}
}
Expand Down Expand Up @@ -440,10 +447,6 @@ function Get-CollectDeps {
New-Item -ItemType Directory -Path $destinationDir
}

# Get the list of dependent DLLs using ldd
Write-BuildInfo "Dry run ldd command: "
& "C:\Program Files\Git\bin\bash.exe" -c "PATH=${combinedPath}:`$PATH ldd $dllFileUnix"

# Start the recursive copying process
Copy-DependentDLLs -dllFileInternal $dllFile -destinationDir $destinationDir -dllDirectories $dllDirectories

Expand Down

0 comments on commit 9be67b6

Please sign in to comment.