2016-09-19 11:50:08 +08:00
|
|
|
[cmdletbinding()]
|
2017-04-12 07:11:28 +08:00
|
|
|
param([string]$targetBinary, [string]$installedDir, [string]$tlogFile, [string]$copiedFilesLog)
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-03-31 18:05:15 +08:00
|
|
|
$g_searched = @{}
|
2017-03-31 19:27:03 +08:00
|
|
|
# Note: installedDir is actually the bin\ directory.
|
|
|
|
$g_install_root = Split-Path $installedDir -parent
|
2018-04-19 10:33:12 +08:00
|
|
|
$g_is_debug = $g_install_root -match '(.*\\)?debug(\\)?$'
|
2017-03-31 18:05:15 +08:00
|
|
|
|
2017-04-26 08:49:13 +08:00
|
|
|
# Ensure we create the copied files log, even if we don't end up copying any files
|
|
|
|
if ($copiedFilesLog)
|
|
|
|
{
|
|
|
|
Set-Content -Path $copiedFilesLog -Value "" -Encoding Ascii
|
|
|
|
}
|
|
|
|
|
2017-03-31 19:27:03 +08:00
|
|
|
# Note: this function signature is depended upon by the qtdeploy.ps1 script introduced in 5.7.1-7
|
|
|
|
function deployBinary([string]$targetBinaryDir, [string]$SourceDir, [string]$targetBinaryName) {
|
2017-03-31 18:11:06 +08:00
|
|
|
if (Test-Path "$targetBinaryDir\$targetBinaryName") {
|
2017-03-31 19:27:03 +08:00
|
|
|
Write-Verbose " ${targetBinaryName}: already present"
|
2017-03-31 18:11:06 +08:00
|
|
|
}
|
|
|
|
else {
|
2017-03-31 19:27:03 +08:00
|
|
|
Write-Verbose " ${targetBinaryName}: Copying $SourceDir\$targetBinaryName"
|
|
|
|
Copy-Item "$SourceDir\$targetBinaryName" $targetBinaryDir
|
2017-03-31 18:11:06 +08:00
|
|
|
}
|
2017-04-12 07:11:28 +08:00
|
|
|
if ($copiedFilesLog) { Add-Content $copiedFilesLog "$targetBinaryDir\$targetBinaryName" }
|
2017-03-31 18:11:06 +08:00
|
|
|
if ($tlogFile) { Add-Content $tlogFile "$targetBinaryDir\$targetBinaryName" }
|
|
|
|
}
|
|
|
|
|
2018-02-08 11:00:11 +08:00
|
|
|
|
|
|
|
Write-Verbose "Resolving base path $targetBinary..."
|
|
|
|
try
|
|
|
|
{
|
|
|
|
$baseBinaryPath = Resolve-Path $targetBinary -erroraction stop
|
|
|
|
$baseTargetBinaryDir = Split-Path $baseBinaryPath -parent
|
|
|
|
}
|
|
|
|
catch [System.Management.Automation.ItemNotFoundException]
|
|
|
|
{
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
# Note: this function signature is depended upon by the qtdeploy.ps1 script
|
2017-03-31 18:11:06 +08:00
|
|
|
function resolve([string]$targetBinary) {
|
2017-03-31 18:05:15 +08:00
|
|
|
Write-Verbose "Resolving $targetBinary..."
|
2017-01-25 07:17:45 +08:00
|
|
|
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
|
|
|
|
|
2016-11-09 11:02:59 +08:00
|
|
|
$a = $(dumpbin /DEPENDENTS $targetBinary | ? { $_ -match "^ [^ ].*\.dll" } | % { $_ -replace "^ ","" })
|
2016-09-19 11:50:08 +08:00
|
|
|
$a | % {
|
2017-01-14 09:39:12 +08:00
|
|
|
if ([string]::IsNullOrEmpty($_)) {
|
2017-03-31 18:05:15 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if ($g_searched.ContainsKey($_)) {
|
|
|
|
Write-Verbose " ${_}: previously searched - Skip"
|
|
|
|
return
|
2017-01-14 09:39:12 +08:00
|
|
|
}
|
2017-03-31 18:05:15 +08:00
|
|
|
$g_searched.Set_Item($_, $true)
|
2016-09-19 11:50:08 +08:00
|
|
|
if (Test-Path "$installedDir\$_") {
|
2018-02-08 11:00:11 +08:00
|
|
|
deployBinary $baseTargetBinaryDir $installedDir "$_"
|
2018-10-23 08:20:34 +08:00
|
|
|
if (Test-Path function:\deployPluginsIfQt) { deployPluginsIfQt $baseTargetBinaryDir "$g_install_root\plugins" "$_" }
|
2018-01-24 00:45:23 +08:00
|
|
|
if (Test-Path function:\deployOpenNI2) { deployOpenNI2 $targetBinaryDir "$g_install_root" "$_" }
|
2018-04-19 10:33:12 +08:00
|
|
|
if (Test-Path function:\deployPluginsIfMagnum) {
|
|
|
|
if ($g_is_debug) {
|
|
|
|
deployPluginsIfMagnum $targetBinaryDir "$g_install_root\bin\magnum-d" "$_"
|
|
|
|
} else {
|
|
|
|
deployPluginsIfMagnum $targetBinaryDir "$g_install_root\bin\magnum" "$_"
|
|
|
|
}
|
|
|
|
}
|
2018-02-08 11:00:11 +08:00
|
|
|
resolve "$baseTargetBinaryDir\$_"
|
2017-07-14 08:47:20 +08:00
|
|
|
} elseif (Test-Path "$targetBinaryDir\$_") {
|
|
|
|
Write-Verbose " ${_}: $_ not found in vcpkg; locally deployed"
|
|
|
|
resolve "$targetBinaryDir\$_"
|
2016-09-19 11:50:08 +08:00
|
|
|
} else {
|
2017-03-31 18:05:15 +08:00
|
|
|
Write-Verbose " ${_}: $installedDir\$_ not found"
|
2016-09-19 11:50:08 +08:00
|
|
|
}
|
|
|
|
}
|
2017-03-31 18:05:15 +08:00
|
|
|
Write-Verbose "Done Resolving $targetBinary."
|
2016-09-19 11:50:08 +08:00
|
|
|
}
|
|
|
|
|
2017-03-31 19:27:03 +08:00
|
|
|
# Note: This is a hack to make Qt5 work.
|
|
|
|
# Introduced with Qt package version 5.7.1-7
|
|
|
|
if (Test-Path "$g_install_root\plugins\qtdeploy.ps1") {
|
|
|
|
. "$g_install_root\plugins\qtdeploy.ps1"
|
|
|
|
}
|
|
|
|
|
2018-01-24 00:45:23 +08:00
|
|
|
# Note: This is a hack to make OpenNI2 work.
|
|
|
|
if (Test-Path "$g_install_root\bin\OpenNI2\openni2deploy.ps1") {
|
|
|
|
. "$g_install_root\bin\OpenNI2\openni2deploy.ps1"
|
|
|
|
}
|
|
|
|
|
2018-04-19 10:33:12 +08:00
|
|
|
# Note: This is a hack to make Magnum work.
|
|
|
|
if (Test-Path "$g_install_root\bin\magnum\magnumdeploy.ps1") {
|
|
|
|
. "$g_install_root\bin\magnum\magnumdeploy.ps1"
|
|
|
|
} elseif (Test-Path "$g_install_root\bin\magnum-d\magnumdeploy.ps1") {
|
|
|
|
. "$g_install_root\bin\magnum-d\magnumdeploy.ps1"
|
|
|
|
}
|
|
|
|
|
2017-03-31 18:05:15 +08:00
|
|
|
resolve($targetBinary)
|
2018-04-19 10:33:12 +08:00
|
|
|
Write-Verbose $($g_searched | out-string)
|