[vcpkg] Add vcpkg item to project settings in Visual Studio (#4361)

Co-authored-by: Curtis J Bezault <curtbezault@gmail.com>
Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
This commit is contained in:
Alexander Neumann 2020-06-15 23:24:14 +02:00 committed by GitHub
parent 36b2f28bbb
commit 14514508d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 204 additions and 73 deletions

View File

@ -1,5 +1,5 @@
Source: fftw3 Source: fftw3
Version: 3.3.8-6 Version: 3.3.8-7
Homepage: https://www.fftw.org/ Homepage: https://www.fftw.org/
Description: FFTW is a C subroutine library for computing the discrete Fourier transform (DFT) in one or more dimensions, of arbitrary input size, and of both real and complex data (as well as of even/odd data, i.e. the discrete cosine/sine transforms or DCT/DST). Description: FFTW is a C subroutine library for computing the discrete Fourier transform (DFT) in one or more dimensions, of arbitrary input size, and of both real and complex data (as well as of even/odd data, i.e. the discrete cosine/sine transforms or DCT/DST).

View File

@ -1,5 +1,3 @@
include(vcpkg_common_functions)
vcpkg_download_distfile(ARCHIVE vcpkg_download_distfile(ARCHIVE
URLS "http://www.fftw.org/fftw-3.3.8.tar.gz" URLS "http://www.fftw.org/fftw-3.3.8.tar.gz"
FILENAME "fftw-3.3.8.tar.gz" FILENAME "fftw-3.3.8.tar.gz"

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<Rule
Name="VcpkgGeneral"
DisplayName="Vcpkg"
PageTemplate="generic"
Description="Vcpkg"
xmlns="http://schemas.microsoft.com/build/2009/properties">
<Rule.Categories>
<Category Name="General" DisplayName="General" Description="General" />
</Rule.Categories>
<Rule.DataSource>
<DataSource Persistence="ProjectFile" Label="Vcpkg" HasConfigurationCondition="true" />
</Rule.DataSource>
<BoolProperty Name="VcpkgEnabled"
DisplayName="Use Vcpkg"
Description="Use Vcpkg for includes and libraries."
Category="General"
Default="true">
</BoolProperty>
<BoolProperty Name="VcpkgUseStatic"
DisplayName="Use static libraries"
Description="Vcpkg can build static libraries (e.g. x64-windows-static). This options changes the default triplet to use these static libraries by appending -static to $(VcpkgTriplet). This will not be shown in the evaluation of the Triplet within the UI."
Category="General"
Default="false">
</BoolProperty>
<BoolProperty Name="VcpkgAutoLink"
DisplayName="Use AutoLink"
Description="Enables automatic linking with libraries build using Vcpkg"
Category="General"
Default="true">
</BoolProperty>
<StringProperty Name="VcpkgUserTriplet"
DisplayName="Triplet"
Description="Specifies the triplet used by Vcpkg"
Category="General"
Subtype="Text">
</StringProperty>
<StringProperty Name="VcpkgRoot"
DisplayName="Vcpkg Root"
Description="Root path where Vcpkg is located. Be careful with changing this one. It is, for example, unable to update this property page from the new location without restarting visual studio."
Category="General"
Subtype="folder"
Visible="false">
</StringProperty>
<StringProperty Name="VcpkgCurrentInstalledDir"
DisplayName="Package install directory"
Description="Defines the direct path to the installed Vcpkg packages. Only change this if you know what you are doing!"
Category="General"
Subtype="folder">
</StringProperty>
<EnumProperty Name="VcpkgConfiguration" DisplayName="Vcpkg Configuration" Description="Specifies if release or debug libraries build with vcpkg should be used." Category="General">
<EnumValue Name="Release" Switch="Release" DisplayName="Release" Description="Uses release libraries">
</EnumValue>
<EnumValue Name="Debug" Switch="Debug" DisplayName="Debug" Description="Uses debug libraries">
</EnumValue>
</EnumProperty>
</Rule>

View File

@ -0,0 +1,35 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VcpkgHasProps>true</VcpkgHasProps>
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
<VcpkgAutoLink Condition="'$(VcpkgAutoLink)' == ''">true</VcpkgAutoLink>
<VcpkgUseStatic Condition="'$(VcpkgUseStatic)' == ''">false</VcpkgUseStatic>
<VcpkgRoot Condition="'$(VcpkgRoot)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), .vcpkg-root))</VcpkgRoot>
<VcpkgConfiguration Condition="'$(VcpkgConfiguration)' == ''">$(Configuration)</VcpkgConfiguration>
<VcpkgPageSchema Condition="'$(VcpkgPageSchema)' == ''">$(VcpkgRoot)\scripts\buildsystems\msbuild\vcpkg-general.xml</VcpkgPageSchema>
</PropertyGroup>
<!-- Set default OS Target-->
<PropertyGroup Condition="'$(ApplicationType)|$(ApplicationTypeRevision)' == 'Windows Store|10.0'">
<VcpkgOSTarget Condition="'$(VcpkgOSTarget)' == ''">uwp</VcpkgOSTarget>
</PropertyGroup>
<PropertyGroup>
<VcpkgOSTarget Condition="'$(VcpkgOSTarget)' == ''">windows</VcpkgOSTarget>
</PropertyGroup>
<!-- Set default Platform Target. $(PlatformTarget) is not available at the top of the .vcxproj file. -->
<PropertyGroup Condition="'$(Platform)' == 'Win32'">
<VcpkgPlatformTarget Condition="'$(VcpkgPlatformTarget)' == ''">x86</VcpkgPlatformTarget>
</PropertyGroup>
<PropertyGroup>
<VcpkgPlatformTarget Condition="'$(VcpkgPlatformTarget)' == ''">$(Platform)</VcpkgPlatformTarget>
</PropertyGroup>
<!-- Set other defaults-->
<PropertyGroup>
<VcpkgUserTriplet Condition="'$(VcpkgUserTriplet)' == ''">$(VcpkgPlatformTarget)-$(VcpkgOSTarget)</VcpkgUserTriplet>
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">$(VcpkgUserTriplet)</VcpkgTriplet>
<VcpkgCurrentInstalledDir Condition="'$(VcpkgCurrentInstalledDir)' == ''">$(VcpkgRoot)\installed\$(VcpkgTriplet)\</VcpkgCurrentInstalledDir>
<VcpkgPageSchema>$(VcpkgRoot)\scripts\buildsystems\msbuild\vcpkg-general.xml</VcpkgPageSchema>
</PropertyGroup>
</Project>

View File

@ -1,64 +1,58 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" TreatAsLocalProperty="VcpkgRoot;VcpkgCurrentInstalledDir"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" TreatAsLocalProperty="VcpkgRoot;VcpkgCurrentInstalledDir">
<PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'Win32||'"> <!-- Setting reasonable defaults if vcpkg.props was not loaded-->
<PropertyGroup Condition="'$(VcpkgHasProps)'!='true'" >
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled> <VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x86-windows</VcpkgTriplet> <VcpkgAutoLink Condition="'$(VcpkgAutoLink)' == ''">true</VcpkgAutoLink>
<VcpkgUseStatic Condition="'$(VcpkgUseStatic)' == ''">false</VcpkgUseStatic>
<VcpkgRoot Condition="'$(VcpkgRoot)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), .vcpkg-root))</VcpkgRoot>
<VcpkgConfiguration Condition="'$(VcpkgConfiguration)' == ''">$(Configuration)</VcpkgConfiguration>
<VcpkgPageSchema Condition="'$(VcpkgPageSchema)' == ''">$(VcpkgRoot)\scripts\buildsystems\msbuild\vcpkg-general.xml</VcpkgPageSchema>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'Win32|Windows Store|10.0'"> <!-- Set default OS Target-->
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled> <PropertyGroup Condition="'$(ApplicationType)|$(ApplicationTypeRevision)' == 'Windows Store|10.0' And '$(VcpkgHasProps)'!='true'">
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x86-uwp</VcpkgTriplet> <VcpkgOSTarget Condition="'$(VcpkgOSTarget)' == ''">uwp</VcpkgOSTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(VcpkgHasProps)'!='true'" >
<VcpkgOSTarget Condition="'$(VcpkgOSTarget)' == ''">windows</VcpkgOSTarget>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == '||'"> <!-- Set other defaults-->
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled> <PropertyGroup Condition="'$(VcpkgHasProps)'!='true'" >
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x86-windows</VcpkgTriplet> <VcpkgUserTriplet Condition="'$(VcpkgUserTriplet)' == ''">$(PlatformTarget)-$(VcpkgOSTarget)</VcpkgUserTriplet>
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">$(VcpkgUserTriplet)</VcpkgTriplet>
<VcpkgCurrentInstalledDir Condition="'$(VcpkgCurrentInstalledDir)' == ''">$(VcpkgRoot)\installed\$(VcpkgTriplet)\</VcpkgCurrentInstalledDir>
</PropertyGroup>
<!--Import property page for vcpkg -->
<ItemGroup Condition="'$(VcpkgPageSchema)' != '' ">
<PropertyPageSchema Include="$(VcpkgPageSchema)">
<Context>Project</Context>
</PropertyPageSchema>
</ItemGroup>
<!-- Update properties if using static libs-->
<PropertyGroup Condition="'$(VcpkgUseStatic)' == 'true'">
<VcpkgTripletTmp>$(VcpkgUserTriplet)</VcpkgTripletTmp>
<VcpkgTriplet>$(VcpkgTripletTmp)-static</VcpkgTriplet>
<VcpkgCurrentInstalledDir Condition="'$(VcpkgCurrentInstalledDir)' == '$(VcpkgRoot)\installed\$(VcpkgTripletTmp)\'">$(VcpkgRoot)\installed\$(VcpkgTriplet)\</VcpkgCurrentInstalledDir>
<VcpkgTripletTmp />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == '|Windows Store|10.0'"> <PropertyGroup Condition="'$(VcpkgUseStatic)' != 'true'">
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled> <VcpkgTripletTmp>$(VcpkgTriplet)</VcpkgTripletTmp>
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x86-uwp</VcpkgTriplet> <VcpkgTriplet Condition="'$(VcpkgTriplet)'!='$(VcpkgUserTriplet)'">$(VcpkgUserTriplet)</VcpkgTriplet>
</PropertyGroup> <VcpkgCurrentInstalledDir Condition="'$(VcpkgCurrentInstalledDir)' == '$(VcpkgRoot)\installed\$(VcpkgTripletTmp)\'">$(VcpkgRoot)\installed\$(VcpkgUserTriplet)\</VcpkgCurrentInstalledDir>
<VcpkgTripletTmp />
<PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'x64||'">
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x64-windows</VcpkgTriplet>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'arm||'">
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">arm-windows</VcpkgTriplet>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'arm64||'">
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">arm64-windows</VcpkgTriplet>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'x64|Windows Store|10.0'">
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x64-uwp</VcpkgTriplet>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'arm|Windows Store|10.0'">
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">arm-uwp</VcpkgTriplet>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'arm64|Windows Store|10.0'">
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">arm64-uwp</VcpkgTriplet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(VcpkgEnabled)' == 'true'"> <PropertyGroup Condition="'$(VcpkgEnabled)' == 'true'">
<VcpkgConfiguration Condition="'$(VcpkgConfiguration)' == ''">$(Configuration)</VcpkgConfiguration>
<VcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Debug'))">Debug</VcpkgNormalizedConfiguration> <VcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Debug'))">Debug</VcpkgNormalizedConfiguration>
<VcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Release')) or '$(VcpkgConfiguration)' == 'RelWithDebInfo' or '$(VcpkgConfiguration)' == 'MinSizeRel'">Release</VcpkgNormalizedConfiguration> <VcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Release')) or '$(VcpkgConfiguration)' == 'RelWithDebInfo' or '$(VcpkgConfiguration)' == 'MinSizeRel'">Release</VcpkgNormalizedConfiguration>
<VcpkgRoot Condition="'$(VcpkgRoot)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), .vcpkg-root))\</VcpkgRoot>
<VcpkgRoot Condition="!$(VcpkgRoot.EndsWith('\'))">$(VcpkgRoot)\</VcpkgRoot> <VcpkgRoot Condition="!$(VcpkgRoot.EndsWith('\'))">$(VcpkgRoot)\</VcpkgRoot>
<VcpkgCurrentInstalledDir Condition="'$(VcpkgCurrentInstalledDir)' == ''">$(VcpkgRoot)installed\$(VcpkgTriplet)\</VcpkgCurrentInstalledDir>
<VcpkgCurrentInstalledDir Condition="!$(VcpkgCurrentInstalledDir.EndsWith('\'))">$(VcpkgCurrentInstalledDir)\</VcpkgCurrentInstalledDir> <VcpkgCurrentInstalledDir Condition="!$(VcpkgCurrentInstalledDir.EndsWith('\'))">$(VcpkgCurrentInstalledDir)\</VcpkgCurrentInstalledDir>
<VcpkgApplocalDeps Condition="'$(VcpkgApplocalDeps)' == ''">true</VcpkgApplocalDeps> <VcpkgApplocalDeps Condition="'$(VcpkgApplocalDeps)' == ''">true</VcpkgApplocalDeps>
<!-- Deactivate Autolinking if lld is used as a linker. (Until a better way to solve the problem is found!). <!-- Deactivate Autolinking if lld is used as a linker. (Until a better way to solve the problem is found!).
Tried to add /lib as a parameter to the linker call but was unable to find a way to pass it as the first parameter. --> Tried to add /lib as a parameter to the linker call but was unable to find a way to pass it as the first parameter. -->
<VcpkgAutoLink Condition="'$(UseLldLink)' == 'true' and '$(VcpkgAutoLink)' == ''">false</VcpkgAutoLink> <VcpkgAutoLink Condition="'$(UseLldLink)' == 'true' and '$(VcpkgAutoLink)' == ''">false</VcpkgAutoLink>
</PropertyGroup> </PropertyGroup>
@ -79,8 +73,8 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<Target Name="VcpkgTripletSelection" BeforeTargets="ClCompile"> <Target Name="VcpkgTripletSelection" BeforeTargets="ClCompile">
<Message Text="Using triplet &quot;$(VcpkgTriplet)&quot; from &quot;$(VcpkgCurrentInstalledDir)&quot;" Importance="Normal" Condition="'$(VcpkgEnabled)' == 'true'"/> <Message Text="Using triplet &quot;$(VcpkgTriplet)&quot; from &quot;$(VcpkgCurrentInstalledDir)&quot;" Importance="High" Condition="'$(VcpkgEnabled)' == 'true'"/>
<Message Text="Not using Vcpkg because VcpkgEnabled is &quot;$(VcpkgEnabled)&quot;" Importance="Normal" Condition="'$(VcpkgEnabled)' != 'true'"/> <Message Text="Not using Vcpkg because VcpkgEnabled is &quot;$(VcpkgEnabled)&quot;" Importance="High" Condition="'$(VcpkgEnabled)' != 'true'"/>
<Message Text="Vcpkg is unable to link because we cannot decide between Release and Debug libraries. Please define the property VcpkgConfiguration to be 'Release' or 'Debug' (currently '$(VcpkgConfiguration)')." Importance="High" Condition="'$(VcpkgEnabled)' == 'true' and '$(VcpkgNormalizedConfiguration)' == ''"/> <Message Text="Vcpkg is unable to link because we cannot decide between Release and Debug libraries. Please define the property VcpkgConfiguration to be 'Release' or 'Debug' (currently '$(VcpkgConfiguration)')." Importance="High" Condition="'$(VcpkgEnabled)' == 'true' and '$(VcpkgNormalizedConfiguration)' == ''"/>
</Target> </Target>
@ -104,4 +98,4 @@
<ReferenceCopyLocalPaths Include="@(VcpkgAppLocalDLLs)" /> <ReferenceCopyLocalPaths Include="@(VcpkgAppLocalDLLs)" />
</ItemGroup> </ItemGroup>
</Target> </Target>
</Project> </Project>

View File

@ -85,6 +85,7 @@ namespace vcpkg
fs::path tools; fs::path tools;
fs::path buildsystems; fs::path buildsystems;
fs::path buildsystems_msbuild_targets; fs::path buildsystems_msbuild_targets;
fs::path buildsystems_msbuild_props;
fs::path vcpkg_dir; fs::path vcpkg_dir;
fs::path vcpkg_dir_status_file; fs::path vcpkg_dir_status_file;

View File

@ -13,7 +13,7 @@
namespace vcpkg::Commands::Integrate namespace vcpkg::Commands::Integrate
{ {
#if defined(_WIN32) #if defined(_WIN32)
static std::string create_appdata_targets_shortcut(const std::string& target_path) noexcept static std::string create_appdata_shortcut(const std::string& target_path) noexcept
{ {
return Strings::format(R"###( return Strings::format(R"###(
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
@ -34,6 +34,7 @@ namespace vcpkg::Commands::Integrate
<PropertyGroup> <PropertyGroup>
<VCLibPackagePath Condition="'$(VCLibPackagePath)' == ''">$(LOCALAPPDATA)\vcpkg\vcpkg.user</VCLibPackagePath> <VCLibPackagePath Condition="'$(VCLibPackagePath)' == ''">$(LOCALAPPDATA)\vcpkg\vcpkg.user</VCLibPackagePath>
</PropertyGroup> </PropertyGroup>
<Import Condition="'$(VCLibPackagePath)' != '' and Exists('$(VCLibPackagePath).props')" Project="$(VCLibPackagePath).props" />
<Import Condition="'$(VCLibPackagePath)' != '' and Exists('$(VCLibPackagePath).targets')" Project="$(VCLibPackagePath).targets" /> <Import Condition="'$(VCLibPackagePath)' != '' and Exists('$(VCLibPackagePath).targets')" Project="$(VCLibPackagePath).targets" />
</Project> </Project>
)###"; )###";
@ -159,6 +160,14 @@ namespace vcpkg::Commands::Integrate
return LOCAL_APP_DATA / fs::u8path("vcpkg/vcpkg.user.targets"); return LOCAL_APP_DATA / fs::u8path("vcpkg/vcpkg.user.targets");
} }
#endif #endif
#if defined(_WIN32)
static fs::path get_appdata_props_path()
{
static const fs::path LOCAL_APP_DATA =
fs::u8path(System::get_environment_variable("LOCALAPPDATA").value_or_exit(VCPKG_LINE_INFO));
return LOCAL_APP_DATA / "vcpkg" / "vcpkg.user.props";
}
#endif
static fs::path get_path_txt_path() { return get_user_dir() / "vcpkg.path.txt"; } static fs::path get_path_txt_path() { return get_user_dir() / "vcpkg.path.txt"; }
@ -248,7 +257,7 @@ namespace vcpkg::Commands::Integrate
const fs::path appdata_src_path = tmp_dir / "vcpkg.user.targets"; const fs::path appdata_src_path = tmp_dir / "vcpkg.user.targets";
fs.write_contents(appdata_src_path, fs.write_contents(appdata_src_path,
create_appdata_targets_shortcut(paths.buildsystems_msbuild_targets.u8string()), create_appdata_shortcut(paths.buildsystems_msbuild_targets.u8string()),
VCPKG_LINE_INFO); VCPKG_LINE_INFO);
auto appdata_dst_path = get_appdata_targets_path(); auto appdata_dst_path = get_appdata_targets_path();
@ -264,6 +273,25 @@ namespace vcpkg::Commands::Integrate
"\n"); "\n");
Checks::exit_fail(VCPKG_LINE_INFO); Checks::exit_fail(VCPKG_LINE_INFO);
} }
const fs::path appdata_src_path2 = tmp_dir / "vcpkg.user.props";
fs.write_contents(appdata_src_path2,
create_appdata_shortcut(paths.buildsystems_msbuild_props.u8string()),
VCPKG_LINE_INFO);
auto appdata_dst_path2 = get_appdata_props_path();
const auto rc2 = fs.copy_file(appdata_src_path2, appdata_dst_path2, fs::copy_options::overwrite_existing, ec);
if (!rc2 || ec)
{
System::print2(System::Color::error,
"Error: Failed to copy file: ",
appdata_src_path2.u8string(),
" -> ",
appdata_dst_path2.u8string(),
"\n");
Checks::exit_fail(VCPKG_LINE_INFO);
}
} }
#endif #endif
@ -304,6 +332,11 @@ CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=%s"
was_deleted |= fs.remove(path, ec); was_deleted |= fs.remove(path, ec);
Checks::check_exit(VCPKG_LINE_INFO, !ec, "Error: Unable to remove user-wide integration: %s", ec.message()); Checks::check_exit(VCPKG_LINE_INFO, !ec, "Error: Unable to remove user-wide integration: %s", ec.message());
const fs::path path2 = get_appdata_props_path();
was_deleted |= fs.remove(path2, ec);
Checks::check_exit(VCPKG_LINE_INFO, !ec, "Error: Unable to remove user-wide integration: %s", ec.message());
#endif #endif
was_deleted |= fs.remove(get_path_txt_path(), ec); was_deleted |= fs.remove(get_path_txt_path(), ec);

View File

@ -25,7 +25,8 @@ namespace vcpkg::Export
using Install::InstallDir; using Install::InstallDir;
static std::string create_nuspec_file_contents(const std::string& raw_exported_dir, static std::string create_nuspec_file_contents(const std::string& raw_exported_dir,
const std::string& targets_redirect_path, const fs::path& targets_redirect_path,
const fs::path& props_redirect_path,
const std::string& nuget_id, const std::string& nuget_id,
const std::string& nupkg_version) const std::string& nupkg_version)
{ {
@ -44,6 +45,7 @@ namespace vcpkg::Export
<file src="@RAW_EXPORTED_DIR@\scripts\**" target="scripts" /> <file src="@RAW_EXPORTED_DIR@\scripts\**" target="scripts" />
<file src="@RAW_EXPORTED_DIR@\.vcpkg-root" target="" /> <file src="@RAW_EXPORTED_DIR@\.vcpkg-root" target="" />
<file src="@TARGETS_REDIRECT_PATH@" target="build\native\@NUGET_ID@.targets" /> <file src="@TARGETS_REDIRECT_PATH@" target="build\native\@NUGET_ID@.targets" />
<file src="@PROPS_REDIRECT_PATH@" target="build\native\@NUGET_ID@.props" />
</files> </files>
</package> </package>
)"; )";
@ -52,8 +54,10 @@ namespace vcpkg::Export
nuspec_file_content = Strings::replace_all(std::move(nuspec_file_content), "@VERSION@", nupkg_version); nuspec_file_content = Strings::replace_all(std::move(nuspec_file_content), "@VERSION@", nupkg_version);
nuspec_file_content = nuspec_file_content =
Strings::replace_all(std::move(nuspec_file_content), "@RAW_EXPORTED_DIR@", raw_exported_dir); Strings::replace_all(std::move(nuspec_file_content), "@RAW_EXPORTED_DIR@", raw_exported_dir);
nuspec_file_content = nuspec_file_content = Strings::replace_all(
Strings::replace_all(std::move(nuspec_file_content), "@TARGETS_REDIRECT_PATH@", targets_redirect_path); std::move(nuspec_file_content), "@TARGETS_REDIRECT_PATH@", targets_redirect_path.u8string());
nuspec_file_content = Strings::replace_all(
std::move(nuspec_file_content), "@PROPS_REDIRECT_PATH@", props_redirect_path.u8string());
return nuspec_file_content; return nuspec_file_content;
} }
@ -136,18 +140,23 @@ namespace vcpkg::Export
Files::Filesystem& fs = paths.get_filesystem(); Files::Filesystem& fs = paths.get_filesystem();
const fs::path& nuget_exe = paths.get_tool_exe(Tools::NUGET); const fs::path& nuget_exe = paths.get_tool_exe(Tools::NUGET);
std::error_code ec;
fs.create_directories(paths.buildsystems / "tmp", ec);
// This file will be placed in "build\native" in the nuget package. Therefore, go up two dirs. // This file will be placed in "build\native" in the nuget package. Therefore, go up two dirs.
const std::string targets_redirect_content = const std::string targets_redirect_content =
create_targets_redirect("$(MSBuildThisFileDirectory)../../scripts/buildsystems/msbuild/vcpkg.targets"); create_targets_redirect("$(MSBuildThisFileDirectory)../../scripts/buildsystems/msbuild/vcpkg.targets");
const fs::path targets_redirect = paths.buildsystems / "tmp" / "vcpkg.export.nuget.targets"; const fs::path targets_redirect = paths.buildsystems / "tmp" / "vcpkg.export.nuget.targets";
std::error_code ec;
fs.create_directories(paths.buildsystems / "tmp", ec);
fs.write_contents(targets_redirect, targets_redirect_content, VCPKG_LINE_INFO); fs.write_contents(targets_redirect, targets_redirect_content, VCPKG_LINE_INFO);
const std::string nuspec_file_content = // This file will be placed in "build\native" in the nuget package. Therefore, go up two dirs.
create_nuspec_file_contents(raw_exported_dir.string(), targets_redirect.string(), nuget_id, nuget_version); const std::string props_redirect_content =
create_targets_redirect("$(MSBuildThisFileDirectory)../../scripts/buildsystems/msbuild/vcpkg.props");
const fs::path props_redirect = paths.buildsystems / "tmp" / "vcpkg.export.nuget.props";
fs.write_contents(props_redirect, props_redirect_content, VCPKG_LINE_INFO);
const std::string nuspec_file_content = create_nuspec_file_contents(
raw_exported_dir.string(), targets_redirect, props_redirect, nuget_id, nuget_version);
const fs::path nuspec_file_path = paths.buildsystems / "tmp" / "vcpkg.export.nuspec"; const fs::path nuspec_file_path = paths.buildsystems / "tmp" / "vcpkg.export.nuspec";
fs.write_contents(nuspec_file_path, nuspec_file_content, VCPKG_LINE_INFO); fs.write_contents(nuspec_file_path, nuspec_file_content, VCPKG_LINE_INFO);
@ -235,6 +244,8 @@ namespace vcpkg::Export
{".vcpkg-root"}, {".vcpkg-root"},
{fs::path{"scripts"} / "buildsystems" / "msbuild" / "applocal.ps1"}, {fs::path{"scripts"} / "buildsystems" / "msbuild" / "applocal.ps1"},
{fs::path{"scripts"} / "buildsystems" / "msbuild" / "vcpkg.targets"}, {fs::path{"scripts"} / "buildsystems" / "msbuild" / "vcpkg.targets"},
{fs::path{"scripts"} / "buildsystems" / "msbuild" / "vcpkg.props"},
{fs::path{"scripts"} / "buildsystems" / "msbuild" / "vcpkg-general.xml"},
{fs::path{"scripts"} / "buildsystems" / "vcpkg.cmake"}, {fs::path{"scripts"} / "buildsystems" / "vcpkg.cmake"},
{fs::path{"scripts"} / "cmake" / "vcpkg_get_windows_sdk.cmake"}, {fs::path{"scripts"} / "cmake" / "vcpkg_get_windows_sdk.cmake"},
}; };
@ -303,9 +314,6 @@ namespace vcpkg::Export
static constexpr StringLiteral OPTION_PREFAB_ENABLE_MAVEN = "--prefab-maven"; static constexpr StringLiteral OPTION_PREFAB_ENABLE_MAVEN = "--prefab-maven";
static constexpr StringLiteral OPTION_PREFAB_ENABLE_DEBUG = "--prefab-debug"; static constexpr StringLiteral OPTION_PREFAB_ENABLE_DEBUG = "--prefab-debug";
static constexpr std::array<CommandSwitch, 11> EXPORT_SWITCHES = {{ static constexpr std::array<CommandSwitch, 11> EXPORT_SWITCHES = {{
{OPTION_DRY_RUN, "Do not actually export"}, {OPTION_DRY_RUN, "Do not actually export"},
{OPTION_RAW, "Export to an uncompressed directory"}, {OPTION_RAW, "Export to an uncompressed directory"},
@ -333,7 +341,7 @@ namespace vcpkg::Export
"Specify the maintainer for the exported Chocolatey package (experimental feature)"}, "Specify the maintainer for the exported Chocolatey package (experimental feature)"},
{OPTION_CHOCOLATEY_VERSION_SUFFIX, {OPTION_CHOCOLATEY_VERSION_SUFFIX,
"Specify the version suffix to add for the exported Chocolatey package (experimental feature)"}, "Specify the version suffix to add for the exported Chocolatey package (experimental feature)"},
{OPTION_PREFAB_GROUP_ID, "GroupId uniquely identifies your project according maven specifications"}, {OPTION_PREFAB_GROUP_ID, "GroupId uniquely identifies your project according maven specifications"},
{OPTION_PREFAB_ARTIFACT_ID, "Artifact Id is the name of the project according maven specifications"}, {OPTION_PREFAB_ARTIFACT_ID, "Artifact Id is the name of the project according maven specifications"},
{OPTION_PREFAB_VERSION, "Version is the name of the project according maven specifications"}, {OPTION_PREFAB_VERSION, "Version is the name of the project according maven specifications"},
{OPTION_PREFAB_SDK_MIN_VERSION, "Android minimum supported sdk version"}, {OPTION_PREFAB_SDK_MIN_VERSION, "Android minimum supported sdk version"},
@ -386,10 +394,12 @@ namespace vcpkg::Export
}); });
} }
if (!ret.raw && !ret.nuget && !ret.ifw && !ret.zip && !ret.seven_zip && !ret.dry_run && !ret.chocolatey && !ret.prefab) if (!ret.raw && !ret.nuget && !ret.ifw && !ret.zip && !ret.seven_zip && !ret.dry_run && !ret.chocolatey &&
!ret.prefab)
{ {
System::print2(System::Color::error, System::print2(
"Must provide at least one export type: --raw --nuget --ifw --zip --7zip --chocolatey --prefab\n"); System::Color::error,
"Must provide at least one export type: --raw --nuget --ifw --zip --7zip --chocolatey --prefab\n");
System::print2(COMMAND_STRUCTURE.example_text); System::print2(COMMAND_STRUCTURE.example_text);
Checks::exit_fail(VCPKG_LINE_INFO); Checks::exit_fail(VCPKG_LINE_INFO);
} }
@ -638,7 +648,8 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console
Chocolatey::do_export(export_plan, paths, opts.chocolatey_options); Chocolatey::do_export(export_plan, paths, opts.chocolatey_options);
} }
if(opts.prefab){ if (opts.prefab)
{
Prefab::do_export(export_plan, paths, opts.prefab_options, default_triplet); Prefab::do_export(export_plan, paths, opts.prefab_options, default_triplet);
} }

View File

@ -81,7 +81,7 @@ namespace vcpkg
} }
} }
#if defined(_WIN32) #if defined(_WIN32)
// fixup Windows drive letter to uppercase // fixup Windows drive letter to uppercase
const auto& nativeRoot = root.native(); const auto& nativeRoot = root.native();
if (nativeRoot.size() > 2 && (nativeRoot[0] >= L'a' && nativeRoot[0] <= L'z') && nativeRoot[1] == L':') if (nativeRoot.size() > 2 && (nativeRoot[0] >= L'a' && nativeRoot[0] <= L'z') && nativeRoot[1] == L':')
@ -90,7 +90,7 @@ namespace vcpkg
uppercaseFirstLetter[0] = nativeRoot[0] - L'a' + L'A'; uppercaseFirstLetter[0] = nativeRoot[0] - L'a' + L'A';
root = uppercaseFirstLetter; root = uppercaseFirstLetter;
} }
#endif // defined(_WIN32) #endif // defined(_WIN32)
Checks::check_exit(VCPKG_LINE_INFO, !root.empty(), "Error: Could not detect vcpkg-root."); Checks::check_exit(VCPKG_LINE_INFO, !root.empty(), "Error: Could not detect vcpkg-root.");
Debug::print("Using vcpkg-root: ", root.u8string(), '\n'); Debug::print("Using vcpkg-root: ", root.u8string(), '\n');
@ -117,7 +117,9 @@ namespace vcpkg
tools = downloads / fs::u8path("tools"); tools = downloads / fs::u8path("tools");
buildsystems = scripts / fs::u8path("buildsystems"); buildsystems = scripts / fs::u8path("buildsystems");
buildsystems_msbuild_targets = buildsystems / fs::u8path("msbuild") / fs::u8path("vcpkg.targets"); const auto msbuildDirectory = buildsystems / fs::u8path("msbuild");
buildsystems_msbuild_targets = msbuildDirectory / fs::u8path("vcpkg.targets");
buildsystems_msbuild_props = msbuildDirectory / fs::u8path("vcpkg.props");
vcpkg_dir = installed / fs::u8path("vcpkg"); vcpkg_dir = installed / fs::u8path("vcpkg");
vcpkg_dir_status_file = vcpkg_dir / fs::u8path("status"); vcpkg_dir_status_file = vcpkg_dir / fs::u8path("status");