Skip to content
Open
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
10 changes: 1 addition & 9 deletions include/vcpkg/base/message-data.inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,6 @@ DECLARE_MESSAGE(AutomaticLinkingForMSBuildProjects,
"",
"All MSBuild C++ projects can now #include any installed libraries. Linking will be handled "
"automatically. Installing new libraries will make them instantly available.")
DECLARE_MESSAGE(AutomaticLinkingForVS2017AndLater,
(),
"",
"Visual Studio 2017 and later can now #include any installed libraries. Linking will be handled "
"automatically. Installing new libraries will make them instantly available.")
DECLARE_MESSAGE(AutoSettingEnvVar,
(msg::env_var, msg::url),
"An example of env_var is \"HTTP(S)_PROXY\""
Expand Down Expand Up @@ -1851,7 +1846,7 @@ DECLARE_MESSAGE(IntegrateInstallHelpLinux, (), "", "Makes installed packages ava
DECLARE_MESSAGE(IntegrateInstallHelpWindows,
(),
"",
"Makes installed packages available user-wide. Requires admin privileges on first use")
"Makes installed packages available to MSBuild C++ projects for the current user")
DECLARE_MESSAGE(IntegrateNonWindowsOnly,
(msg::command_line),
"",
Expand All @@ -1870,7 +1865,6 @@ DECLARE_MESSAGE(IntegrateZshHelp,
(),
"'zsh' is a terminal program which should be unlocalized.",
"Enable zsh tab-completion. Non-Windows only")
DECLARE_MESSAGE(IntegrationFailedVS2015, (), "", "Integration was not applied for Visual Studio 2015.")
DECLARE_MESSAGE(InternalCICommand,
(),
"",
Expand Down Expand Up @@ -2680,7 +2674,6 @@ DECLARE_MESSAGE(PortVersionControlMustBeANonNegativeInteger, (), "", "\"Port-Ver
DECLARE_MESSAGE(PrebuiltPackages, (), "", "There are packages that have not been built. To build them run:")
DECLARE_MESSAGE(PrecheckBinaryCache, (), "", "Checking the binary cache...")
DECLARE_MESSAGE(PreviousDeclarationWasHere, (), "", "previous declaration was here")
DECLARE_MESSAGE(PreviousIntegrationFileRemains, (), "", "Previous integration file was not removed.")
DECLARE_MESSAGE(ProgramReturnedNonzeroExitCode,
(msg::tool_name, msg::exit_code),
"The program's console output is appended after this.",
Expand Down Expand Up @@ -2837,7 +2830,6 @@ DECLARE_MESSAGE(SystemApiErrorMessage,
(msg::system_api, msg::exit_code, msg::error_msg),
"",
"calling {system_api} failed with {exit_code} ({error_msg})")
DECLARE_MESSAGE(SystemTargetsInstallFailed, (msg::path), "", "failed to install system targets file to {path}")
DECLARE_MESSAGE(
ToolHashMismatch,
(msg::tool_name, msg::expected, msg::actual),
Expand Down
3 changes: 0 additions & 3 deletions include/vcpkg/commands.integrate.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#include <vcpkg/base/fwd/optional.h>

#include <vcpkg/fwd/vcpkgcmdarguments.h>
#include <vcpkg/fwd/vcpkgpaths.h>

Expand All @@ -15,7 +13,6 @@ namespace vcpkg
extern const CommandMetadata CommandIntegrateMetadata;
void command_integrate_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths);

Optional<int> find_targets_file_version(StringView contents);
std::vector<std::string> get_bash_source_completion_lines(StringView contents);

struct ZshAutocomplete
Expand Down
7 changes: 1 addition & 6 deletions locales/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@
"AutoSettingEnvVar": "-- Automatically setting {env_var} environment variables to \"{url}\".",
"_AutoSettingEnvVar.comment": "An example of env_var is \"HTTP(S)_PROXY\"'--' at the beginning must be preserved An example of {env_var} is VCPKG_DEFAULT_TRIPLET. An example of {url} is https://github.com/microsoft/vcpkg.",
"AutomaticLinkingForMSBuildProjects": "All MSBuild C++ projects can now #include any installed libraries. Linking will be handled automatically. Installing new libraries will make them instantly available.",
"AutomaticLinkingForVS2017AndLater": "Visual Studio 2017 and later can now #include any installed libraries. Linking will be handled automatically. Installing new libraries will make them instantly available.",
"AvailableHelpTopics": "Available help topics:",
"AzUrlAssetCacheRequiresBaseUrl": "unexpected arguments: asset config 'azurl' requires a base url",
"AzUrlAssetCacheRequiresLessThanFour": "unexpected arguments: asset config 'azurl' requires fewer than 4 arguments",
Expand Down Expand Up @@ -1014,7 +1013,7 @@
"IntegrateFishHelp": "Enable fish tab-completion. Non-Windows only",
"_IntegrateFishHelp.comment": "'fish' is a terminal program which should be unlocalized.",
"IntegrateInstallHelpLinux": "Makes installed packages available user-wide",
"IntegrateInstallHelpWindows": "Makes installed packages available user-wide. Requires admin privileges on first use",
"IntegrateInstallHelpWindows": "Makes installed packages available to MSBuild C++ projects for the current user",
"IntegrateNonWindowsOnly": "{command_line} is non-Windows-only and not supported on this system.",
"_IntegrateNonWindowsOnly.comment": "An example of {command_line} is vcpkg install zlib.",
"IntegratePowerShellHelp": "Enable PowerShell tab-completion. Windows-only",
Expand All @@ -1024,7 +1023,6 @@
"_IntegrateWindowsOnly.comment": "An example of {command_line} is vcpkg install zlib.",
"IntegrateZshHelp": "Enable zsh tab-completion. Non-Windows only",
"_IntegrateZshHelp.comment": "'zsh' is a terminal program which should be unlocalized.",
"IntegrationFailedVS2015": "Integration was not applied for Visual Studio 2015.",
"InternalCICommand": "vcpkg ci is an internal command which will change incompatibly or be removed at any time.",
"InternalErrorMessageContact": "Please open an issue at https://github.com/microsoft/vcpkg/issues/new?template=other-type-of-bug-report.md&labels=category:vcpkg-bug with detailed steps to reproduce the problem.",
"InvalidArchitectureValue": "Invalid architecture: {value}. Expected one of: {expected}",
Expand Down Expand Up @@ -1385,7 +1383,6 @@
"PrebuiltPackages": "There are packages that have not been built. To build them run:",
"PrecheckBinaryCache": "Checking the binary cache...",
"PreviousDeclarationWasHere": "previous declaration was here",
"PreviousIntegrationFileRemains": "Previous integration file was not removed.",
"ProgramPathReturnedNonzeroExitCode": "failed with exit code {exit_code}",
"_ProgramPathReturnedNonzeroExitCode.comment": "An example of {exit_code} is 127.",
"ProgramReturnedNonzeroExitCode": "{tool_name} failed with exit code: ({exit_code}).",
Expand Down Expand Up @@ -1468,8 +1465,6 @@
"_SynopsisHeader.comment": "Printed before a description of what a command does",
"SystemApiErrorMessage": "calling {system_api} failed with {exit_code} ({error_msg})",
"_SystemApiErrorMessage.comment": "An example of {system_api} is CreateProcessW. An example of {exit_code} is 127. An example of {error_msg} is File Not Found.",
"SystemTargetsInstallFailed": "failed to install system targets file to {path}",
"_SystemTargetsInstallFailed.comment": "An example of {path} is /foo/bar.",
"ToRemovePackages": "To only remove outdated packages, run\n{command_name} remove --outdated",
"_ToRemovePackages.comment": "An example of {command_name} is install.",
"ToUpdatePackages": "To update these packages and all dependencies, run\n{command_name} upgrade'",
Expand Down
54 changes: 0 additions & 54 deletions src/vcpkg-test/integrate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,6 @@

using namespace vcpkg;

TEST_CASE ("find_targets_file_version", "[integrate]")
{
constexpr static StringLiteral DEFAULT_TARGETS_FILE = R"xml(
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- version 1 -->
<PropertyGroup>
<VCLibPackagePath Condition="'$(VCLibPackagePath)' == ''">$(LOCALAPPDATA)\vcpkg\vcpkg.user</VCLibPackagePath>
</PropertyGroup>
<Import Condition="'$(VCLibPackagePath)' != '' and Exists('$(VCLibPackagePath).props')" Project="$(VCLibPackagePath).props" />
<Import Condition="'$(VCLibPackagePath)' != '' and Exists('$(VCLibPackagePath).targets')" Project="$(VCLibPackagePath).targets" />
</Project>
)xml";

auto res = find_targets_file_version(DEFAULT_TARGETS_FILE);
REQUIRE(res.has_value());
CHECK(*res.get() == 1);

res = find_targets_file_version("<!-- version 12345 -->");
REQUIRE(res.has_value());
CHECK(*res.get() == 12345);

res = find_targets_file_version("<!-- version <!-- version 1 -->");
REQUIRE(res.has_value());
CHECK(*res.get() == 1);

res = find_targets_file_version("<!-- version 32 <!-- version 1 -->");
REQUIRE(res.has_value());
CHECK(*res.get() == 1);

res = find_targets_file_version("<!-- version 32 --> <!-- version 1 -->");
REQUIRE(res.has_value());
CHECK(*res.get() == 32);

res = find_targets_file_version("<!-- version 12345 -->");
CHECK_FALSE(res.has_value());

res = find_targets_file_version("<!-- version 12345 -->");
CHECK_FALSE(res.has_value());

res = find_targets_file_version("<!-- version -12345 -->");
CHECK_FALSE(res.has_value());

res = find_targets_file_version("<!-- version -12345 --> <!-- version 1 -->");
REQUIRE(res.has_value());
CHECK(*res.get() == 1);

res = find_targets_file_version("<!-- version unexpected --> <!-- version 1 -->");
REQUIRE(res.has_value());
CHECK(*res.get() == 1);

res = find_targets_file_version("<!-- ver 1 -->");
CHECK_FALSE(res.has_value());
}

TEST_CASE ("get_bash_source_completion_lines", "[integrate]")
{
const std::string default_bashrc = R"sh(
Expand Down
144 changes: 0 additions & 144 deletions src/vcpkg/commands.integrate.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <vcpkg/base/system-headers.h>

#include <vcpkg/base/fwd/message_sinks.h>

#include <vcpkg/base/checks.h>
Expand All @@ -19,34 +17,6 @@

namespace vcpkg
{
Optional<int> find_targets_file_version(StringView contents)
{
constexpr static StringLiteral VERSION_START = "<!-- version ";
constexpr static StringLiteral VERSION_END = " -->";

auto first = contents.begin();
const auto last = contents.end();
for (;;)
{
first = Util::search_and_skip(first, last, VERSION_START);
if (first == last)
{
break;
}
auto version_end = Util::search(first, last, VERSION_END);
if (version_end == last)
{
break;
}
auto ver = Strings::strto<int>({first, version_end});
if (ver.has_value() && *ver.get() >= 0)
{
return ver;
}
}
return nullopt;
}

std::vector<std::string> get_bash_source_completion_lines(StringView contents)
{
std::vector<std::string> matches;
Expand Down Expand Up @@ -125,17 +95,6 @@ namespace vcpkg
target_path);
}

static constexpr StringLiteral SystemTargetsShortcut = R"###(
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- version 1 -->
<PropertyGroup>
<VCLibPackagePath Condition="'$(VCLibPackagePath)' == ''">$(LOCALAPPDATA)\vcpkg\vcpkg.user</VCLibPackagePath>
</PropertyGroup>
<Import Condition="'$(VCLibPackagePath)' != '' and Exists('$(VCLibPackagePath).props')" Project="$(VCLibPackagePath).props" />
<Import Condition="'$(VCLibPackagePath)' != '' and Exists('$(VCLibPackagePath).targets')" Project="$(VCLibPackagePath).targets" />
</Project>
)###";

static std::string create_nuget_targets_file_contents(const Path& msbuild_vcpkg_targets_file)
{
return fmt::format(R"###(
Expand Down Expand Up @@ -204,102 +163,6 @@ namespace vcpkg
}
#endif // ^^^ _WIN32

#if defined(_WIN32)
enum class ElevationPromptChoice
{
YES,
NO
};

static ElevationPromptChoice elevated_cmd_execute(const std::string& param)
{
SHELLEXECUTEINFOW sh_ex_info{};
sh_ex_info.cbSize = sizeof(sh_ex_info);
sh_ex_info.fMask = SEE_MASK_NOCLOSEPROCESS;
sh_ex_info.hwnd = nullptr;
sh_ex_info.lpVerb = L"runas";
sh_ex_info.lpFile = L"cmd"; // Application to start

auto wparam = Strings::to_utf16(param);
sh_ex_info.lpParameters = wparam.c_str(); // Additional parameters
sh_ex_info.lpDirectory = nullptr;
sh_ex_info.nShow = SW_HIDE;
sh_ex_info.hInstApp = nullptr;

if (!ShellExecuteExW(&sh_ex_info))
{
return ElevationPromptChoice::NO;
}
if (sh_ex_info.hProcess == nullptr)
{
return ElevationPromptChoice::NO;
}
WaitForSingleObject(sh_ex_info.hProcess, INFINITE);
CloseHandle(sh_ex_info.hProcess);
return ElevationPromptChoice::YES;
}
#endif // ^^^ _WIN32

#if defined(_WIN32)
static bool integrate_install_msbuild14(const Filesystem& fs)
{
Path OLD_SYSTEM_TARGET_FILES[] = {
get_program_files_32_bit().value_or_exit(VCPKG_LINE_INFO) /
"MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.nuget.targets",
get_program_files_32_bit().value_or_exit(VCPKG_LINE_INFO) /
"MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.system.targets"};

Path SYSTEM_WIDE_TARGETS_FILE = get_program_files_32_bit().value_or_exit(VCPKG_LINE_INFO) /
"MSBuild/Microsoft.Cpp/v4.0/V140/ImportBefore/Default/vcpkg.system.props";

// TODO: This block of code should eventually be removed
for (auto&& old_system_wide_targets_file : OLD_SYSTEM_TARGET_FILES)
{
if (fs.exists(old_system_wide_targets_file, IgnoreErrors{}))
{
const std::string param = fmt::format(R"(/d /c "DEL "{}" /Q > nul")", old_system_wide_targets_file);
const ElevationPromptChoice user_choice = elevated_cmd_execute(param);
switch (user_choice)
{
case ElevationPromptChoice::YES: break;
case ElevationPromptChoice::NO: msg::println_warning(msgPreviousIntegrationFileRemains); break;
default: Checks::unreachable(VCPKG_LINE_INFO);
}
}
}

std::error_code ec;
std::string system_wide_file_contents = fs.read_contents(SYSTEM_WIDE_TARGETS_FILE, ec);
if (!ec)
{
auto opt = find_targets_file_version(system_wide_file_contents);
if (opt.value_or(0) >= 1)
{
return true;
}
}

const auto tmp_dir = fs.create_or_get_temp_directory(VCPKG_LINE_INFO);
const auto sys_src_path = tmp_dir / "vcpkg.system.targets";
fs.write_contents(sys_src_path, SystemTargetsShortcut, VCPKG_LINE_INFO);

const std::string param = fmt::format(R"(/d /c "mkdir "{}" & copy "{}" "{}" /Y > nul")",
SYSTEM_WIDE_TARGETS_FILE.parent_path(),
sys_src_path,
SYSTEM_WIDE_TARGETS_FILE);
elevated_cmd_execute(param);
fs.remove_all(tmp_dir, VCPKG_LINE_INFO);

if (!fs.exists(SYSTEM_WIDE_TARGETS_FILE, IgnoreErrors{}))
{
msg::println_warning(msg::format(msgSystemTargetsInstallFailed, msg::path = SYSTEM_WIDE_TARGETS_FILE));
return false;
}

return true;
}
#endif // ^^^ _WIN32

static void integrate_install(const VcpkgPaths& paths)
{
auto& fs = paths.get_filesystem();
Expand All @@ -319,13 +182,6 @@ namespace vcpkg
create_appdata_shortcut(paths.buildsystems_msbuild_targets),
VCPKG_LINE_INFO);

if (!integrate_install_msbuild14(fs))
{
message.append_raw("\n\n").append(msgAutomaticLinkingForVS2017AndLater);
msg::println(message);
Checks::msg_exit_with_message(VCPKG_LINE_INFO, msgIntegrationFailedVS2015);
}

message.append_raw("\n\n").append(msgAutomaticLinkingForMSBuildProjects);
Comment thread
BillyONeal marked this conversation as resolved.
#endif // ^^^ _WIN32

Expand Down
Loading