Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 65 additions & 39 deletions scripts/buildsystems/msbuild/applocal.ps1
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -102,61 +105,84 @@ 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."
}

# 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)
Expand Down
2 changes: 1 addition & 1 deletion scripts/buildsystems/msbuild/vcpkg.targets
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
Condition="'$(_ZVcpkgClassicOrManifest)' == 'true' and '$(VcpkgApplocalDeps)' == 'true' and '$(LinkSkippedExecution)' != 'true'">
<Message Text="[vcpkg] Starting VcpkgApplocalDeps" Importance="low" />
<PropertyGroup>
<_ZVcpkgAppLocalPowerShellCommonArguments>-ExecutionPolicy Bypass -noprofile -File "$(MSBuildThisFileDirectory)applocal.ps1" "$(TargetPath)" "$(_ZVcpkgCurrentInstalledDir)$(_ZVcpkgConfigSubdir)bin" "$(TLogLocation)$(ProjectName).write.1u.tlog" "$(IntDir)vcpkg.applocal.log"</_ZVcpkgAppLocalPowerShellCommonArguments>
<_ZVcpkgAppLocalPowerShellCommonArguments>-ExecutionPolicy Bypass -noprofile -File "$(MSBuildThisFileDirectory)applocal.ps1" -tlogFile "$(TLogLocation)$(ProjectName).write.1u.tlog" -copiedFilesLog "$(IntDir)vcpkg.applocal.log" -targetBinary "$(TargetPath)" "$(_ZVcpkgCurrentInstalledDir)$(_ZVcpkgConfigSubdir)bin"</_ZVcpkgAppLocalPowerShellCommonArguments>
</PropertyGroup>
<!-- Search %PATH% for pwsh.exe if it is available. -->
<Exec
Expand Down
16 changes: 10 additions & 6 deletions scripts/buildsystems/vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -598,15 +598,16 @@ function(add_executable)
if(VCPKG_APPLOCAL_DEPS)
if(Z_VCPKG_TARGET_TRIPLET_PLAT MATCHES "windows|uwp|xbox")
z_vcpkg_set_powershell_path()
z_vcpkg_add_vcpkg_to_cmake_path(INSTALLED_DIRS "/bin")
set(EXTRA_OPTIONS "")
if(X_VCPKG_APPLOCAL_DEPS_SERIALIZED)
set(EXTRA_OPTIONS USES_TERMINAL)
endif()
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 "$<TARGET_FILE:${target_name}>"
-installedDir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin"
-OutVariable out
-targetBinary "$<TARGET_FILE:${target_name}>"
${INSTALLED_DIRS}
VERBATIM
${EXTRA_OPTIONS}
)
Expand Down Expand Up @@ -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 "$<TARGET_FILE:${target_name}>"
-installedDir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin"
-OutVariable out
-targetBinary "$<TARGET_FILE:${target_name}>"
${INSTALLED_DIRS}
VERBATIM
)
endif()
Expand Down Expand Up @@ -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}/$<TARGET_FILE_NAME:${target}>\"
-installedDir \"${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin\"
-OutVariable out)"
\${INSTALLED_DIRS})"
${component_param}
)
endif()
Expand Down
4 changes: 2 additions & 2 deletions scripts/cmake/vcpkg_copy_tool_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
Expand Down