From 97e7ac8d748779d04ab1c230abb59f4473a227ed Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Thu, 2 Sep 2021 12:33:21 -0700 Subject: [vcpkg] Repair msbuild damage and workaround the way we integrate on VS2015. (#19767) * Repair msbuild damage and workaround the way we integrate on VS2015. This is a fix for a pile of issues discovered by https://github.com/microsoft/vcpkg/pull/18906 * VS 2015 has a bug that the $(VcpkgInstalledDir)\ dance we do to get a trailing slash is not applied correctly when VcpkgInstalledDir was edited in the same property group attempting to add the trailing slash. * We need a trailing slash on VcpkgInstalledDir at all times, but https://github.com/microsoft/vcpkg/pull/16173 damaged this by removing it from TreatAsLocalProperty. Add the right TreatAsLocalPropertys back. Add all such slash defenses to the top of the file just beneath, eliminating need to call Path::Combine and friends by following msbuild "directory properties have a trailing slash" convention. * Move VcpkgOSTarget and VcpkgPlatformTarget into the .targets, as they aren't intended to be overridable by users and don't appear in our selection dialog box(es). * Don't bother avoiding setting vcpkg properties when VcpkgEnabled is off; after all, VcpkgEnabled is itself a vcpkg property :). I left attempts to skip creating items since creating items can hit the disk. * Add _Z to several internal msbuild variables. * Move VcpkgApplocalDeps to the .props since it's a user setting. * Don't unconditionally use $(TLogLocation) because it is not set on 2015, and also it's per-project. * Fixed typo in docs "VcpkgInstalledDirectory", and document the limitation that it doesn't work in 2015. * In manifest mode, put the installed tree in a subdirectory including the triplet to make changing configurations faster. Known limitations: * If you change vcpkg.json without changing any .cpp files, we don't rebuild the dependencies even though we should. I don't know how to fix this but it doesn't appear to be a regression. * Fix .tlog handling. * Further defend against modified properties on VS2015. * Document more VS2015 limitations. * Remove TreatAsLocalProperty comment. --- scripts/buildsystems/msbuild/vcpkg.props | 17 +-- scripts/buildsystems/msbuild/vcpkg.targets | 179 ++++++++++++++++++----------- 2 files changed, 116 insertions(+), 80 deletions(-) (limited to 'scripts') diff --git a/scripts/buildsystems/msbuild/vcpkg.props b/scripts/buildsystems/msbuild/vcpkg.props index 788ba107b..9a01beb5a 100644 --- a/scripts/buildsystems/msbuild/vcpkg.props +++ b/scripts/buildsystems/msbuild/vcpkg.props @@ -1,34 +1,21 @@ - - - - windows - uwp - - - - - $(Platform) - x86 - - true true $(Configuration) false - $([System.IO.Path]::Combine($(MSBuildThisFileDirectory), '..\..\..')) + $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\..')) true false + true false true $([MSbuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), vcpkg.json)) - diff --git a/scripts/buildsystems/msbuild/vcpkg.targets b/scripts/buildsystems/msbuild/vcpkg.targets index 7653c4e91..98fde24f1 100644 --- a/scripts/buildsystems/msbuild/vcpkg.targets +++ b/scripts/buildsystems/msbuild/vcpkg.targets @@ -1,53 +1,91 @@ - + - - - - $([System.IO.Path]::Combine($(VcpkgRoot), 'scripts\buildsystems\msbuild\vcpkg-general.xml')) - - - - - - -static - $(VcpkgPlatformTarget)-$(VcpkgOSTarget)$(VcpkgLinkage) + - $([System.IO.Path]::Combine($(VcpkgRoot), 'installed')) - $([System.IO.Path]::Combine($(VcpkgManifestRoot), 'vcpkg_installed')) - $(VcpkgInstalledDir)\ + + <_ZVcpkgRoot>$(VcpkgRoot) + <_ZVcpkgManifestRoot>$(VcpkgManifestRoot) + <_ZVcpkgInstalledDir>$(VcpkgInstalledDir) + - <_ZVcpkgCurrentInstalledDir>$([System.IO.Path]::Combine($(VcpkgInstalledDir), $(VcpkgTriplet))) - <_ZVcpkgCurrentInstalledDir Condition="!$(_ZVcpkgCurrentInstalledDir.EndsWith('\'))">$(_ZVcpkgCurrentInstalledDir)\ + + + <_ZVcpkgRoot Condition="!$(_ZVcpkgRoot.EndsWith('\'))">$(_ZVcpkgRoot)\ + <_ZVcpkgManifestRoot Condition="'$(_ZVcpkgManifestRoot)' != '' and !$(_ZVcpkgManifestRoot.EndsWith('\'))">$(_ZVcpkgManifestRoot)\ + <_ZVcpkgInstalledDir Condition="'$(_ZVcpkgInstalledDir)' != '' and !$(_ZVcpkgInstalledDir.EndsWith('\'))">$(_ZVcpkgInstalledDir)\ + - Debug - Release + + + windows + uwp + - debug\ - true + + $(Platform) + x86 + - <_ZVcpkgHostTripletParameter Condition="'$(VcpkgHostTriplet)' != ''">"--host-triplet=$(VcpkgHostTriplet)" - <_ZVcpkgExecutable>$([System.IO.Path]::Combine($(VcpkgRoot), 'vcpkg.exe')) + + <_ZVcpkgLinkage /> + <_ZVcpkgLinkage Condition="'$(VcpkgUseStatic)' == 'true'">-static + $(VcpkgPlatformTarget)-$(VcpkgOSTarget)$(_ZVcpkgLinkage) + + + VcpkgTriplet=$(VcpkgTriplet):$(ProjectStateLine) - - + + + + + <_ZVcpkgInstalledDir Condition="'$(_ZVcpkgInstalledDir)' == ''">$(_ZVcpkgManifestRoot)vcpkg_installed\$(VcpkgTriplet)\ + + + + + <_ZVcpkgInstalledDir Condition="'$(_ZVcpkgInstalledDir)' == ''">$(_ZVcpkgRoot)installed\ + + + + + + <_ZVcpkgCurrentInstalledDir>$(_ZVcpkgInstalledDir)\$(VcpkgTriplet)\ + <_ZVcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Debug'))">Debug + <_ZVcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Release')) or '$(VcpkgConfiguration)' == 'RelWithDebInfo' or '$(VcpkgConfiguration)' == 'MinSizeRel'">Release + + <_ZVcpkgConfigSubdir Condition="'$(_ZVcpkgNormalizedConfiguration)' == 'Debug'">debug\ + <_ZVcpkgExecutable>$(_ZVcpkgRoot)vcpkg.exe + + + + + $(_ZVcpkgRoot)scripts\buildsystems\msbuild\vcpkg-general.xml + + + Project + - %(AdditionalDependencies);$(_ZVcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)lib\*.lib - %(AdditionalLibraryDirectories);$(_ZVcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)lib;$(_ZVcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)lib\manual-link + %(AdditionalDependencies);$(_ZVcpkgCurrentInstalledDir)$(_ZVcpkgConfigSubdir)lib\*.lib + %(AdditionalLibraryDirectories);$(_ZVcpkgCurrentInstalledDir)$(_ZVcpkgConfigSubdir)lib;$(_ZVcpkgCurrentInstalledDir)$(_ZVcpkgConfigSubdir)lib\manual-link %(AdditionalIncludeDirectories);$(_ZVcpkgCurrentInstalledDir)include @@ -59,9 +97,9 @@ - + Condition="'$(VcpkgEnableManifest)' == 'true' and '$(_ZVcpkgManifestRoot)' == ''" /> + @@ -70,41 +108,52 @@ + Importance="High" Condition="'$(VcpkgEnabled)' == 'true' and '$(_ZVcpkgNormalizedConfiguration)' == ''"/> - - <_ZVcpkgManifestFileLocation>$(VcpkgManifestRoot)vcpkg.json - <_ZVcpkgConfigurationFileLocation>$(VcpkgManifestRoot)vcpkg-configuration.json - - <_ZVcpkgTLogFileLocation>$(TLogLocation)VcpkgInstallManifest$(VcpkgTriplet).$(VcpkgHostTriplet).read.1u.tlog - <_ZVcpkgMSBuildStampFile>$(VcpkgInstalledDir).msbuildstamp-$(VcpkgTriplet).$(VcpkgHostTriplet).stamp + + + + <_ZVcpkgHostTripletParameter>"--host-triplet=$(VcpkgHostTriplet)" + <_ZVcpkgHostTripletSuffix>$(VcpkgHostTriplet). + + + + + <_ZVcpkgHostTripletParameter /> + <_ZVcpkgHostTripletSuffix /> + + + + + + <_ZVcpkgManifestFileLocation>$(_ZVcpkgManifestRoot)vcpkg.json + <_ZVcpkgConfigurationFileLocation>$(_ZVcpkgManifestRoot)vcpkg-configuration.json + <_ZVcpkgMSBuildStampFile>$(_ZVcpkgInstalledDir).msbuildstamp-$(VcpkgTriplet).$(_ZVcpkgHostTripletSuffix)stamp + <_ZVcpkgInstallManifestDependenciesInputs Include="$(_ZVcpkgManifestFileLocation)"/> <_ZVcpkgInstallManifestDependenciesInputs Include="$(_ZVcpkgConfigurationFileLocation)" Condition="Exists('$(_ZVcpkgConfigurationFileLocation)')"/> - - <_ZVcpkgInstallManifestDependenciesOutputs Include="$(_ZVcpkgTLogFileLocation)"/> - <_ZVcpkgInstallManifestDependenciesOutputs Include="$(_ZVcpkgMSBuildStampFile)"/> - - - - <_ZVcpkgItemToDelete Include="$(TLogLocation)VcpkgInstallManifest*.read.1u.tlog" /> - <_ZVcpkgItemToDelete Include="$(VcpkgInstalledDir).msbuildstamp-*" /> - - - + + + <_ZVcpkgTLogFileLocation>$(TLogLocation)VcpkgInstallManifest$(VcpkgTriplet).$(_ZVcpkgHostTripletSuffix)read.1u.tlog + + + + + - @@ -118,40 +167,40 @@ Condition="'$(VcpkgEnabled)' == 'true' and '$(VcpkgApplocalDeps)' == 'true' and '$(LinkSkippedExecution)' != 'true'"> - <_VcpkgAppLocalPowerShellCommonArguments>-ExecutionPolicy Bypass -noprofile -File "$(MSBuildThisFileDirectory)applocal.ps1" "$(TargetPath)" "$(_ZVcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)bin" "$(TLogLocation)$(ProjectName).write.1u.tlog" "$(IntDir)vcpkg.applocal.log" + <_ZVcpkgAppLocalPowerShellCommonArguments>-ExecutionPolicy Bypass -noprofile -File "$(MSBuildThisFileDirectory)applocal.ps1" "$(TargetPath)" "$(_ZVcpkgCurrentInstalledDir)$(_ZVcpkgConfigSubdir)bin" "$(TLogLocation)$(ProjectName).write.1u.tlog" "$(IntDir)vcpkg.applocal.log" + PropertyName="_ZVcpkgAppLocalExitCode" /> + Condition="$(_ZVcpkgAppLocalExitCode) == 9009" /> + Condition="$(_ZVcpkgAppLocalExitCode) == 9009"> + PropertyName="_ZVcpkgAppLocalExitCode" /> - + + Condition="$(_ZVcpkgAppLocalExitCode) == 0"> - - + + -- cgit v1.2.3