mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-28 19:25:27 +08:00
[applocal.ps1] Keep global set of searched binaries and avoid excessive recursion.
This commit is contained in:
parent
044c20dee0
commit
1c9fd4aefc
@ -1,7 +1,10 @@
|
|||||||
[cmdletbinding()]
|
[cmdletbinding()]
|
||||||
param([string]$targetBinary, [string]$installedDir, [string]$tlogFile)
|
param([string]$targetBinary, [string]$installedDir, [string]$tlogFile)
|
||||||
|
|
||||||
|
$g_searched = @{}
|
||||||
|
|
||||||
function resolve($targetBinary) {
|
function resolve($targetBinary) {
|
||||||
|
Write-Verbose "Resolving $targetBinary..."
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$targetBinaryPath = Resolve-Path $targetBinary -erroraction stop
|
$targetBinaryPath = Resolve-Path $targetBinary -erroraction stop
|
||||||
@ -15,23 +18,30 @@ function resolve($targetBinary) {
|
|||||||
$a = $(dumpbin /DEPENDENTS $targetBinary | ? { $_ -match "^ [^ ].*\.dll" } | % { $_ -replace "^ ","" })
|
$a = $(dumpbin /DEPENDENTS $targetBinary | ? { $_ -match "^ [^ ].*\.dll" } | % { $_ -replace "^ ","" })
|
||||||
$a | % {
|
$a | % {
|
||||||
if ([string]::IsNullOrEmpty($_)) {
|
if ([string]::IsNullOrEmpty($_)) {
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
if ($g_searched.ContainsKey($_)) {
|
||||||
|
Write-Verbose " ${_}: previously searched - Skip"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
$g_searched.Set_Item($_, $true)
|
||||||
if (Test-Path "$installedDir\$_") {
|
if (Test-Path "$installedDir\$_") {
|
||||||
if (Test-Path "$targetBinaryDir\$_") {
|
if (Test-Path "$targetBinaryDir\$_") {
|
||||||
Write-Verbose "$_ is already present"
|
Write-Verbose " ${_}: already present - Only recurse"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Copy-Item $installedDir\$_ $targetBinaryDir
|
Copy-Item $installedDir\$_ $targetBinaryDir
|
||||||
Write-Verbose "Copying $installedDir\$_ -> $_"
|
Write-Verbose " ${_}: Copying $installedDir\$_"
|
||||||
}
|
}
|
||||||
"$targetBinaryDir\$_"
|
"$targetBinaryDir\$_"
|
||||||
if ($tlogFile) { Add-Content $tlogFile "$targetBinaryDir\$_" }
|
if ($tlogFile) { Add-Content $tlogFile "$targetBinaryDir\$_" }
|
||||||
resolve("$targetBinaryDir\$_")
|
resolve("$targetBinaryDir\$_")
|
||||||
} else {
|
} else {
|
||||||
Write-Verbose "$installedDir\$_ not found"
|
Write-Verbose " ${_}: $installedDir\$_ not found"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Write-Verbose "Done Resolving $targetBinary."
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve($targetBinary)
|
resolve($targetBinary)
|
||||||
|
Write-Verbose $($g_searched | out-string)
|
Loading…
x
Reference in New Issue
Block a user