From 6c9b62eea3bc432628ad97b892025714ba6f4b6b Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Tue, 20 Sep 2016 14:25:28 -0700 Subject: [PATCH] [vcpkg] Fix mismatch between props and targets for user integration. --- toolsrc/src/commands_integration.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/toolsrc/src/commands_integration.cpp b/toolsrc/src/commands_integration.cpp index e1b63038a..0156d5e2a 100644 --- a/toolsrc/src/commands_integration.cpp +++ b/toolsrc/src/commands_integration.cpp @@ -9,6 +9,7 @@ #include "vcpkg_Environment.h" #include "vcpkg_Checks.h" #include "vcpkg_System.h" +#include "vcpkg_Files.h" namespace vcpkg { @@ -28,10 +29,11 @@ namespace vcpkg { return R"###( + $(LOCALAPPDATA)\vcpkg\vcpkg.user - + )###"; } @@ -165,7 +167,25 @@ namespace vcpkg fs::create_directory(paths.buildsystems); fs::create_directory(tmp_dir); - if (!fs::exists(system_wide_targets_file)) + bool should_install_system = true; + if (fs::exists(system_wide_targets_file)) + { + auto system_wide_file_contents = Files::get_contents(system_wide_targets_file); + if (auto contents_data = system_wide_file_contents.get()) + { + std::regex re(R"###()###"); + std::match_results match; + auto found = std::regex_search(*contents_data, match, re); + if (found) + { + int ver = atoi(match[1].str().c_str()); + if (ver >= 1) + should_install_system = false; + } + } + } + + if (should_install_system) { const fs::path sys_src_path = tmp_dir / "vcpkg.system.targets"; std::ofstream(sys_src_path) << create_system_targets_shortcut();