diff --git a/scripts/buildsystems/msbuild/applocal.ps1 b/scripts/buildsystems/msbuild/applocal.ps1
index 05e11c52ca3cc2..c1edb1be8db238 100644
--- a/scripts/buildsystems/msbuild/applocal.ps1
+++ b/scripts/buildsystems/msbuild/applocal.ps1
@@ -1,10 +1,13 @@
[cmdletbinding()]
-param([string]$targetBinary, [string]$installedDir, [string]$tlogFile, [string]$copiedFilesLog)
+param(
+ [string]$tlogFile,
+ [string]$copiedFilesLog,
+ [string]$targetBinary,
+ [Parameter(Mandatory, Position = 0, ValueFromRemainingArguments)]
+ [string[]]$installedDirs
+)
$g_searched = @{}
-# Note: installedDir is actually the bin\ directory.
-$g_install_root = Split-Path $installedDir -parent
-$g_is_debug = (Split-Path $g_install_root -leaf) -eq 'debug'
# Ensure we create the copied files log, even if we don't end up copying any files
if ($copiedFilesLog)
@@ -102,35 +105,41 @@ function resolve([string]$targetBinary) {
} else {
Write-Error "Neither dumpbin, llvm-objdump nor objdump could be found. Can not take care of dll dependencies."
}
- $a | % {
- if ([string]::IsNullOrEmpty($_)) {
- return
+ foreach ($installedItem in $a) {
+ if ([string]::IsNullOrEmpty($installedItem)) {
+ continue
}
- if ($g_searched.ContainsKey($_)) {
- Write-Verbose " ${_}: previously searched - Skip"
- return
+ if ($g_searched.ContainsKey($installedItem)) {
+ Write-Verbose " ${installedItem}: previously searched - Skip"
+ continue
}
- $g_searched.Set_Item($_, $true)
- $installedItemFilePath = Join-Path $installedDir $_
- $targetItemFilePath = Join-Path $targetBinaryDir $_
- if (Test-Path $installedItemFilePath) {
- deployBinary $baseTargetBinaryDir $installedDir "$_"
- if (Test-Path function:\deployPluginsIfQt) { deployPluginsIfQt $baseTargetBinaryDir (Join-Path $g_install_root 'plugins') "$_" }
- if (Test-Path function:\deployOpenNI2) { deployOpenNI2 $targetBinaryDir "$g_install_root" "$_" }
- if (Test-Path function:\deployPluginsIfMagnum) {
- if ($g_is_debug) {
- deployPluginsIfMagnum $targetBinaryDir (Join-Path (Join-Path "$g_install_root" 'bin') 'magnum-d') "$_"
- } else {
- deployPluginsIfMagnum $targetBinaryDir (Join-Path (Join-Path "$g_install_root" 'bin') 'magnum') "$_"
+ $g_searched.Set_Item($installedItem, $true)
+ foreach ($installedDir in $installedDirs) {
+ # Note: installedDir is actually the bin\ directory.
+ $installRoot = Split-Path $installedDir -parent
+ $installedItemFilePath = Join-Path $installedDir $installedItem
+ $targetItemFilePath = Join-Path $targetBinaryDir $installedItem
+ if (Test-Path $installedItemFilePath) {
+ deployBinary $baseTargetBinaryDir $installedDir "$installedItem"
+ if (Test-Path function:\deployPluginsIfQt) { deployPluginsIfQt $baseTargetBinaryDir (Join-Path $installRoot 'plugins') "$installedItem" }
+ if (Test-Path function:\deployOpenNI2) { deployOpenNI2 $targetBinaryDir "$installRoot" "$installedItem" }
+ if (Test-Path function:\deployPluginsIfMagnum) {
+ if ((Split-Path $installRoot -leaf) -eq 'debug') {
+ deployPluginsIfMagnum $targetBinaryDir (Join-Path (Join-Path "$installRoot" 'bin') 'magnum-d') "$installedItem"
+ } else {
+ deployPluginsIfMagnum $targetBinaryDir (Join-Path (Join-Path "$installRoot" 'bin') 'magnum') "$installedItem"
+ }
}
+ if (Test-Path function:\deployAzureKinectSensorSDK) { deployAzureKinectSensorSDK $targetBinaryDir "$installRoot" "$installedItem" }
+ resolve (Join-Path $baseTargetBinaryDir "$installedItem")
+ break
+ } elseif (Test-Path $targetItemFilePath) {
+ Write-Verbose " ${installedItem}: $installedItem not found in $installRoot; locally deployed"
+ resolve "$targetItemFilePath"
+ break
+ } else {
+ Write-Verbose " ${installedItem}: $installedItemFilePath not found"
}
- if (Test-Path function:\deployAzureKinectSensorSDK) { deployAzureKinectSensorSDK $targetBinaryDir "$g_install_root" "$_" }
- resolve (Join-Path $baseTargetBinaryDir "$_")
- } elseif (Test-Path $targetItemFilePath) {
- Write-Verbose " ${_}: $_ not found in $g_install_root; locally deployed"
- resolve "$targetItemFilePath"
- } else {
- Write-Verbose " ${_}: $installedItemFilePath not found"
}
}
Write-Verbose "Done Resolving $targetBinary."
@@ -138,25 +147,42 @@ function resolve([string]$targetBinary) {
# 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"
+foreach ($installedDir in $installedDirs) {
+ $installedRoot = Split-Path $installedDir -parent
+ if (Test-Path "$installedDir\plugins\qtdeploy.ps1") {
+ . "$g_install_root\plugins\qtdeploy.ps1"
+ break
+ }
}
# 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"
+foreach ($installedDir in $installedDirs) {
+ $installedRoot = Split-Path $installedDir -parent
+ if (Test-Path "$g_install_root\bin\OpenNI2\openni2deploy.ps1") {
+ . "$g_install_root\bin\OpenNI2\openni2deploy.ps1"
+ break
+ }
}
# 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"
+foreach ($installedDir in $installedDirs) {
+ $installedRoot = Split-Path $installedDir -parent
+ if (Test-Path "$g_install_root\bin\magnum\magnumdeploy.ps1") {
+ . "$g_install_root\bin\magnum\magnumdeploy.ps1"
+ break
+ } elseif (Test-Path "$g_install_root\bin\magnum-d\magnumdeploy.ps1") {
+ . "$g_install_root\bin\magnum-d\magnumdeploy.ps1"
+ break
+ }
}
# Note: This is a hack to make Azure Kinect Sensor SDK work.
-if (Test-Path "$g_install_root\tools\azure-kinect-sensor-sdk\k4adeploy.ps1") {
- . "$g_install_root\tools\azure-kinect-sensor-sdk\k4adeploy.ps1"
+foreach ($installedDir in $installedDirs) {
+ $installedRoot = Split-Path $installedDir -parent
+ if (Test-Path "$g_install_root\tools\azure-kinect-sensor-sdk\k4adeploy.ps1") {
+ . "$g_install_root\tools\azure-kinect-sensor-sdk\k4adeploy.ps1"
+ break
+ }
}
resolve($targetBinary)
diff --git a/scripts/buildsystems/msbuild/vcpkg.targets b/scripts/buildsystems/msbuild/vcpkg.targets
index 361850bd838031..6a3f06a46df4b7 100644
--- a/scripts/buildsystems/msbuild/vcpkg.targets
+++ b/scripts/buildsystems/msbuild/vcpkg.targets
@@ -199,7 +199,7 @@
Condition="'$(_ZVcpkgClassicOrManifest)' == 'true' and '$(VcpkgApplocalDeps)' == 'true' and '$(LinkSkippedExecution)' != 'true'">
- <_ZVcpkgAppLocalPowerShellCommonArguments>-ExecutionPolicy Bypass -noprofile -File "$(MSBuildThisFileDirectory)applocal.ps1" "$(TargetPath)" "$(_ZVcpkgCurrentInstalledDir)$(_ZVcpkgConfigSubdir)bin" "$(TLogLocation)$(ProjectName).write.1u.tlog" "$(IntDir)vcpkg.applocal.log"
+ <_ZVcpkgAppLocalPowerShellCommonArguments>-ExecutionPolicy Bypass -noprofile -File "$(MSBuildThisFileDirectory)applocal.ps1" -tlogFile "$(TLogLocation)$(ProjectName).write.1u.tlog" -copiedFilesLog "$(IntDir)vcpkg.applocal.log" -targetBinary "$(TargetPath)" "$(_ZVcpkgCurrentInstalledDir)$(_ZVcpkgConfigSubdir)bin"
"
- -installedDir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$:/debug>/bin"
-OutVariable out
+ -targetBinary "$"
+ ${INSTALLED_DIRS}
VERBATIM
${EXTRA_OPTIONS}
)
@@ -639,11 +640,12 @@ function(add_library)
get_target_property(IS_LIBRARY_SHARED "${target_name}" TYPE)
if(VCPKG_APPLOCAL_DEPS AND Z_VCPKG_TARGET_TRIPLET_PLAT MATCHES "windows|uwp|xbox" AND (IS_LIBRARY_SHARED STREQUAL "SHARED_LIBRARY" OR IS_LIBRARY_SHARED STREQUAL "MODULE_LIBRARY"))
z_vcpkg_set_powershell_path()
+ z_vcpkg_add_vcpkg_to_cmake_path(INSTALLED_DIRS "/bin")
add_custom_command(TARGET "${target_name}" POST_BUILD
COMMAND "${Z_VCPKG_POWERSHELL_PATH}" -noprofile -executionpolicy Bypass -file "${Z_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1"
- -targetBinary "$"
- -installedDir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$:/debug>/bin"
-OutVariable out
+ -targetBinary "$"
+ ${INSTALLED_DIRS}
VERBATIM
)
endif()
@@ -695,11 +697,13 @@ function(x_vcpkg_install_local_dependencies)
foreach(target IN LISTS arg_TARGETS)
get_target_property(target_type "${target}" TYPE)
if(NOT target_type STREQUAL "INTERFACE_LIBRARY")
+ z_vcpkg_add_vcpkg_to_cmake_path(INSTALLED_DIRS "/bin")
install(CODE "message(\"-- Installing app dependencies for ${target}...\")
+ set(INSTALLED_DIRS \"${INSTALLED_DIRS}\")
execute_process(COMMAND \"${Z_VCPKG_POWERSHELL_PATH}\" -noprofile -executionpolicy Bypass -file \"${Z_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1\"
+ -OutVariable out
-targetBinary \"${arg_DESTINATION}/$\"
- -installedDir \"${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$:/debug>/bin\"
- -OutVariable out)"
+ \${INSTALLED_DIRS})"
${component_param}
)
endif()
diff --git a/scripts/cmake/vcpkg_copy_tool_dependencies.cmake b/scripts/cmake/vcpkg_copy_tool_dependencies.cmake
index cf3939bacbe5c4..f7549fbc0d4db9 100644
--- a/scripts/cmake/vcpkg_copy_tool_dependencies.cmake
+++ b/scripts/cmake/vcpkg_copy_tool_dependencies.cmake
@@ -9,9 +9,9 @@ function(z_vcpkg_copy_tool_dependencies_search tool_dir path_to_search)
vcpkg_execute_required_process(
COMMAND "${Z_VCPKG_POWERSHELL_CORE}" -noprofile -executionpolicy Bypass -nologo
-file "${SCRIPTS}/buildsystems/msbuild/applocal.ps1"
- -targetBinary "${tool}"
- -installedDir "${path_to_search}"
-verbose
+ -targetBinary "${tool}"
+ "${path_to_search}"
WORKING_DIRECTORY "${VCPKG_ROOT_DIR}"
LOGNAME copy-tool-dependencies-${count}
)