vcpkg/scripts/buildsystems/msbuild/applocal.ps1

47 lines
1.5 KiB
PowerShell
Raw Normal View History

2016-09-19 11:50:08 +08:00
[cmdletbinding()]
param([string]$targetBinary, [string]$installedDir, [string]$tlogFile)
$g_searched = @{}
2016-09-19 11:50:08 +08:00
function resolve($targetBinary) {
Write-Verbose "Resolving $targetBinary..."
try
{
$targetBinaryPath = Resolve-Path $targetBinary -erroraction stop
}
catch [System.Management.Automation.ItemNotFoundException]
{
return
}
2016-09-19 11:50:08 +08:00
$targetBinaryDir = Split-Path $targetBinaryPath -parent
$a = $(dumpbin /DEPENDENTS $targetBinary | ? { $_ -match "^ [^ ].*\.dll" } | % { $_ -replace "^ ","" })
2016-09-19 11:50:08 +08:00
$a | % {
if ([string]::IsNullOrEmpty($_)) {
return
}
if ($g_searched.ContainsKey($_)) {
Write-Verbose " ${_}: previously searched - Skip"
return
}
$g_searched.Set_Item($_, $true)
2016-09-19 11:50:08 +08:00
if (Test-Path "$installedDir\$_") {
if (Test-Path "$targetBinaryDir\$_") {
Write-Verbose " ${_}: already present - Only recurse"
2016-09-19 11:50:08 +08:00
}
else {
Copy-Item $installedDir\$_ $targetBinaryDir
Write-Verbose " ${_}: Copying $installedDir\$_"
2016-09-19 11:50:08 +08:00
}
"$targetBinaryDir\$_"
if ($tlogFile) { Add-Content $tlogFile "$targetBinaryDir\$_" }
resolve("$targetBinaryDir\$_")
} else {
Write-Verbose " ${_}: $installedDir\$_ not found"
2016-09-19 11:50:08 +08:00
}
}
Write-Verbose "Done Resolving $targetBinary."
2016-09-19 11:50:08 +08:00
}
resolve($targetBinary)
Write-Verbose $($g_searched | out-string)