diff --git a/toolsrc/include/vcpkg/base/chrono.h b/toolsrc/include/vcpkg/base/chrono.h index 26294fdf847..89cd152737f 100644 --- a/toolsrc/include/vcpkg/base/chrono.h +++ b/toolsrc/include/vcpkg/base/chrono.h @@ -56,8 +56,8 @@ namespace vcpkg::Chrono static Optional get_current_date_time(); static Optional parse(CStringView str); - constexpr CTime() noexcept : m_tm {0} {} - explicit constexpr CTime(tm t) noexcept : m_tm {t} {} + constexpr CTime() noexcept : m_tm{0} {} + explicit constexpr CTime(tm t) noexcept : m_tm{t} {} CTime add_hours(const int hours) const; diff --git a/toolsrc/include/vcpkg/base/strings.h b/toolsrc/include/vcpkg/base/strings.h index 3165dc8eee8..3a9de97df85 100644 --- a/toolsrc/include/vcpkg/base/strings.h +++ b/toolsrc/include/vcpkg/base/strings.h @@ -43,7 +43,7 @@ namespace vcpkg::Strings::details t.to_string(into); } - template(), std::declval()))> + template(), std::declval()))> void append_internal(std::string& into, const T& t) { to_string(into, t); @@ -66,7 +66,8 @@ namespace vcpkg::Strings } template - [[nodiscard]] std::string concat(const Args&... args) { + [[nodiscard]] std::string concat(const Args&... args) + { std::string ret; append(ret, args...); return ret; @@ -113,8 +114,7 @@ namespace vcpkg::Strings bool starts_with(StringView s, StringView pattern); template - std::string join(const char* delimiter, InputIterator begin, InputIterator end, - Transformer transformer) + std::string join(const char* delimiter, InputIterator begin, InputIterator end, Transformer transformer) { if (begin == end) { @@ -145,8 +145,7 @@ namespace vcpkg::Strings std::string join(const char* delimiter, InputIterator begin, InputIterator end) { using Element = decltype(*begin); - return join(delimiter, begin, end, - [](const Element& x) -> const Element& { return x; }); + return join(delimiter, begin, end, [](const Element& x) -> const Element& { return x; }); } template diff --git a/toolsrc/src/tests.arguments.cpp b/toolsrc/src/tests.arguments.cpp index c87281fa8cf..72bdbdb6532 100644 --- a/toolsrc/src/tests.arguments.cpp +++ b/toolsrc/src/tests.arguments.cpp @@ -33,8 +33,8 @@ namespace UnitTest1 TEST_METHOD(create_from_arg_sequence_valued_options) { - std::array settings = { {{"--a", ""}} }; - CommandStructure cmdstruct = { "", 0, SIZE_MAX, {{}, settings }, nullptr }; + std::array settings = {{{"--a", ""}}}; + CommandStructure cmdstruct = {"", 0, SIZE_MAX, {{}, settings}, nullptr}; std::vector t = {"--a=b", "command", "argument"}; auto v = VcpkgCmdArguments::create_from_arg_sequence(t.data(), t.data() + t.size()); @@ -47,8 +47,8 @@ namespace UnitTest1 TEST_METHOD(create_from_arg_sequence_valued_options2) { - std::array switches = { {{"--a", ""}, {"--c", ""}} }; - std::array settings = { { {"--b", ""}, {"--d", ""}} }; + std::array switches = {{{"--a", ""}, {"--c", ""}}}; + std::array settings = {{{"--b", ""}, {"--d", ""}}}; CommandStructure cmdstruct = {"", 0, SIZE_MAX, {switches, settings}, nullptr}; std::vector t = {"--a", "--b=c"}; diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index 9102205d8c5..ab7586eebec 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -388,6 +388,6 @@ int main(const int argc, const char* const* const argv) } fflush(stdout); - //It is expected that one of the sub-commands will exit cleanly before we get here. + // It is expected that one of the sub-commands will exit cleanly before we get here. Checks::exit_fail(VCPKG_LINE_INFO); } diff --git a/toolsrc/src/vcpkg/archives.cpp b/toolsrc/src/vcpkg/archives.cpp index 037cbdc1472..69a916828d1 100644 --- a/toolsrc/src/vcpkg/archives.cpp +++ b/toolsrc/src/vcpkg/archives.cpp @@ -1,8 +1,8 @@ #include "pch.h" #include -#include #include +#include namespace vcpkg::Archives { diff --git a/toolsrc/src/vcpkg/base/chrono.cpp b/toolsrc/src/vcpkg/base/chrono.cpp index 959ff90c8be..86dc590f8ff 100644 --- a/toolsrc/src/vcpkg/base/chrono.cpp +++ b/toolsrc/src/vcpkg/base/chrono.cpp @@ -22,7 +22,7 @@ namespace vcpkg::Chrono static tm to_local_time(const std::time_t& t) { - tm parts {}; + tm parts{}; #if defined(_WIN32) localtime_s(&parts, &t); #else @@ -33,7 +33,7 @@ namespace vcpkg::Chrono static Optional to_utc_time(const std::time_t& t) { - tm parts {}; + tm parts{}; #if defined(_WIN32) const errno_t err = gmtime_s(&parts, &t); if (err) @@ -127,7 +127,7 @@ namespace vcpkg::Chrono const Optional opt = to_utc_time(ct); if (auto p_tm = opt.get()) { - return CTime {*p_tm}; + return CTime{*p_tm}; } return nullopt; @@ -160,11 +160,11 @@ namespace vcpkg::Chrono return ret; } - CTime CTime::add_hours(const int hours) const { return CTime {date_plus_hours(&this->m_tm, hours)}; } + CTime CTime::add_hours(const int hours) const { return CTime{date_plus_hours(&this->m_tm, hours)}; } std::string CTime::to_string() const { - std::array date {}; + std::array date{}; strftime(&date[0], date.size(), "%Y-%m-%dT%H:%M:%S.0Z", &m_tm); return &date[0]; } diff --git a/toolsrc/src/vcpkg/base/downloads.cpp b/toolsrc/src/vcpkg/base/downloads.cpp index 590c48ff520..218ff86b3d7 100644 --- a/toolsrc/src/vcpkg/base/downloads.cpp +++ b/toolsrc/src/vcpkg/base/downloads.cpp @@ -44,18 +44,20 @@ namespace vcpkg::Downloads Checks::check_exit(VCPKG_LINE_INFO, hSession, "WinHttpOpen() failed: %d", GetLastError()); // Win7 IE Proxy fallback - if (IsWindows7OrGreater() && !IsWindows8Point1OrGreater()) { + if (IsWindows7OrGreater() && !IsWindows8Point1OrGreater()) + { // First check if any proxy has been found automatically - WINHTTP_PROXY_INFO proxyInfo; - DWORD proxyInfoSize = sizeof(WINHTTP_PROXY_INFO); - auto noProxyFound = - !WinHttpQueryOption(hSession, WINHTTP_OPTION_PROXY, &proxyInfo, &proxyInfoSize) - || proxyInfo.dwAccessType == WINHTTP_ACCESS_TYPE_NO_PROXY; - - // If no proxy was found automatically, use IE's proxy settings, if any - if (noProxyFound) { + WINHTTP_PROXY_INFO proxyInfo; + DWORD proxyInfoSize = sizeof(WINHTTP_PROXY_INFO); + auto noProxyFound = !WinHttpQueryOption(hSession, WINHTTP_OPTION_PROXY, &proxyInfo, &proxyInfoSize) || + proxyInfo.dwAccessType == WINHTTP_ACCESS_TYPE_NO_PROXY; + + // If no proxy was found automatically, use IE's proxy settings, if any + if (noProxyFound) + { WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ieProxy; - if (WinHttpGetIEProxyConfigForCurrentUser(&ieProxy) && ieProxy.lpszProxy != nullptr) { + if (WinHttpGetIEProxyConfigForCurrentUser(&ieProxy) && ieProxy.lpszProxy != nullptr) + { WINHTTP_PROXY_INFO proxy; proxy.dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY; proxy.lpszProxy = ieProxy.lpszProxy; diff --git a/toolsrc/src/vcpkg/base/files.cpp b/toolsrc/src/vcpkg/base/files.cpp index 43149131439..0396a241550 100644 --- a/toolsrc/src/vcpkg/base/files.cpp +++ b/toolsrc/src/vcpkg/base/files.cpp @@ -9,10 +9,10 @@ #if defined(__linux__) || defined(__APPLE__) #include +#include #include #include #include -#include #endif #if defined(__linux__) #include diff --git a/toolsrc/src/vcpkg/base/system.cpp b/toolsrc/src/vcpkg/base/system.cpp index 132c1f0749d..48a701bfa69 100644 --- a/toolsrc/src/vcpkg/base/system.cpp +++ b/toolsrc/src/vcpkg/base/system.cpp @@ -177,8 +177,8 @@ namespace vcpkg } std::string System::make_cmake_cmd(const fs::path& cmake_exe, - const fs::path& cmake_script, - const std::vector& pass_variables) + const fs::path& cmake_script, + const std::vector& pass_variables) { const std::string cmd_cmake_pass_variables = Strings::join(" ", pass_variables, [](auto&& v) { return v.s; }); return Strings::format( @@ -345,7 +345,8 @@ namespace vcpkg } #endif - int System::cmd_execute_clean(const ZStringView cmd_line, const std::unordered_map& extra_env) + int System::cmd_execute_clean(const ZStringView cmd_line, + const std::unordered_map& extra_env) { auto timer = Chrono::ElapsedTimer::create_started(); #if defined(_WIN32) diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index 1f28e9f30c2..7bd6f467b7d 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -6,9 +6,9 @@ #include #include #include +#include #include #include -#include #include #include @@ -360,14 +360,13 @@ namespace vcpkg::Build const Toolset& toolset = paths.get_toolset(pre_build_info); - std::vector variables { + std::vector variables{ {"CMD", "BUILD"}, {"PORT", config.scf.core_paragraph->name}, {"CURRENT_PORT_DIR", config.port_dir}, {"TARGET_TRIPLET", spec.triplet().canonical_name()}, {"VCPKG_PLATFORM_TOOLSET", toolset.version.c_str()}, - {"VCPKG_USE_HEAD_VERSION", - Util::Enum::to_bool(config.build_package_options.use_head_version) ? "1" : "0"}, + {"VCPKG_USE_HEAD_VERSION", Util::Enum::to_bool(config.build_package_options.use_head_version) ? "1" : "0"}, {"DOWNLOADS", paths.downloads}, {"_VCPKG_NO_DOWNLOADS", !Util::Enum::to_bool(config.build_package_options.allow_downloads) ? "1" : "0"}, {"_VCPKG_DOWNLOAD_TOOL", to_string(config.build_package_options.download_tool)}, @@ -380,10 +379,7 @@ namespace vcpkg::Build variables.push_back({"GIT", git_exe_path}); } - const std::string cmd_launch_cmake = System::make_cmake_cmd( - cmake_exe_path, - paths.ports_cmake, - variables); + const std::string cmd_launch_cmake = System::make_cmake_cmd(cmake_exe_path, paths.ports_cmake, variables); auto command = make_build_env_cmd(pre_build_info, toolset); if (!command.empty()) @@ -484,14 +480,14 @@ namespace vcpkg::Build // the order of recursive_directory_iterator is undefined so save the names to sort std::vector port_files; - for (auto &port_file : fs::stdfs::recursive_directory_iterator(config.port_dir)) + for (auto& port_file : fs::stdfs::recursive_directory_iterator(config.port_dir)) { if (fs::is_regular_file(status(port_file))) { port_files.push_back(port_file); if (port_files.size() > max_port_file_count) { - abi_tag_entries.emplace_back(AbiEntry{ "no_hash_max_portfile", "" }); + abi_tag_entries.emplace_back(AbiEntry{"no_hash_max_portfile", ""}); break; } } @@ -502,7 +498,7 @@ namespace vcpkg::Build std::sort(port_files.begin(), port_files.end()); int counter = 0; - for (auto & port_file : port_files) + for (auto& port_file : port_files) { // When vcpkg takes a dependency on C++17 it can use fs::relative, // which will give a stable ordering and better names in the key entry. @@ -512,7 +508,7 @@ namespace vcpkg::Build { System::print2("[DEBUG] mapping ", key, " from ", port_file.u8string(), "\n"); } - abi_tag_entries.emplace_back(AbiEntry{ key, vcpkg::Hash::get_file_hash(fs, port_file, "SHA1") }); + abi_tag_entries.emplace_back(AbiEntry{key, vcpkg::Hash::get_file_hash(fs, port_file, "SHA1")}); } } @@ -602,8 +598,8 @@ namespace vcpkg::Build System::cmd_execute_clean(Strings::format( R"("%s" a "%s" "%s\*" >nul)", seven_zip_exe.u8string(), destination.u8string(), source.u8string())); #else - System::cmd_execute_clean(Strings::format( - R"(cd '%s' && zip --quiet -r '%s' *)", source.u8string(), destination.u8string())); + System::cmd_execute_clean( + Strings::format(R"(cd '%s' && zip --quiet -r '%s' *)", source.u8string(), destination.u8string())); #endif } @@ -730,7 +726,7 @@ namespace vcpkg::Build const auto tmp_failure_zip = paths.buildtrees / spec.name() / "failure_logs.zip"; fs.create_directories(tmp_log_path_destination, ec); - for (auto &log_file : fs::stdfs::directory_iterator(paths.buildtrees / spec.name())) + for (auto& log_file : fs::stdfs::directory_iterator(paths.buildtrees / spec.name())) { if (log_file.path().extension() == ".log") { diff --git a/toolsrc/src/vcpkg/commands.ci.cpp b/toolsrc/src/vcpkg/commands.ci.cpp index 4d31c4fbefd..ff7e7a13428 100644 --- a/toolsrc/src/vcpkg/commands.ci.cpp +++ b/toolsrc/src/vcpkg/commands.ci.cpp @@ -55,27 +55,20 @@ namespace vcpkg::Commands::CI struct XunitTestResults { public: + XunitTestResults() { m_assembly_run_datetime = Chrono::CTime::get_current_date_time(); } - XunitTestResults() + void add_test_results(const std::string& spec, + const Build::BuildResult& build_result, + const Chrono::ElapsedTime& elapsed_time, + const std::string& abi_tag) { - m_assembly_run_datetime = Chrono::CTime::get_current_date_time(); - } - - void add_test_results(const std::string& spec, const Build::BuildResult& build_result, const Chrono::ElapsedTime& elapsed_time, const std::string& abi_tag) - { - m_collections.back().tests.push_back({ spec, build_result, elapsed_time, abi_tag }); + m_collections.back().tests.push_back({spec, build_result, elapsed_time, abi_tag}); } // Starting a new test collection - void push_collection( const std::string& name) - { - m_collections.push_back({name}); - } + void push_collection(const std::string& name) { m_collections.push_back({name}); } - void collection_time(const vcpkg::Chrono::ElapsedTime& time) - { - m_collections.back().time = time; - } + void collection_time(const vcpkg::Chrono::ElapsedTime& time) { m_collections.back().time = time; } const std::string& build_xml() { @@ -96,13 +89,9 @@ namespace vcpkg::Commands::CI return m_xml; } - void assembly_time(const vcpkg::Chrono::ElapsedTime& assembly_time) - { - m_assembly_time = assembly_time; - } + void assembly_time(const vcpkg::Chrono::ElapsedTime& assembly_time) { m_assembly_time = assembly_time; } private: - struct XunitTest { std::string name; @@ -126,34 +115,33 @@ namespace vcpkg::Commands::CI auto rawDateTime = m_assembly_run_datetime.get()->to_string(); // The expected format is "yyyy-mm-ddThh:mm:ss.0Z" // 0123456789012345678901 - datetime = Strings::format(R"(run-date="%s" run-time="%s")", - rawDateTime.substr(0, 10), rawDateTime.substr(11, 8)); + datetime = Strings::format( + R"(run-date="%s" run-time="%s")", rawDateTime.substr(0, 10), rawDateTime.substr(11, 8)); } std::string time = Strings::format(R"(time="%lld")", m_assembly_time.as().count()); - m_xml += Strings::format( - R"()" "\n" - R"( )" "\n" - , datetime, time); + m_xml += Strings::format(R"()" + "\n" + R"( )" + "\n", + datetime, + time); } void xml_finish_assembly() { m_xml += " \n" - "\n"; + "\n"; } void xml_start_collection(const XunitCollection& collection) { m_xml += Strings::format(R"( )" - "\n", - collection.name, - collection.time.as().count()); - } - void xml_finish_collection() - { - m_xml += " \n"; + "\n", + collection.name, + collection.time.as().count()); } + void xml_finish_collection() { m_xml += " \n"; } void xml_test(const XunitTest& test) { @@ -161,23 +149,20 @@ namespace vcpkg::Commands::CI const char* result_string = ""; switch (test.result) { - case BuildResult::POST_BUILD_CHECKS_FAILED: - case BuildResult::FILE_CONFLICTS: - case BuildResult::BUILD_FAILED: - result_string = "Fail"; - message_block = Strings::format("", to_string(test.result)); - break; - case BuildResult::EXCLUDED: - case BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES: - result_string = "Skip"; - message_block = Strings::format("", to_string(test.result)); - break; - case BuildResult::SUCCEEDED: - result_string = "Pass"; - break; - default: - Checks::exit_fail(VCPKG_LINE_INFO); - break; + case BuildResult::POST_BUILD_CHECKS_FAILED: + case BuildResult::FILE_CONFLICTS: + case BuildResult::BUILD_FAILED: + result_string = "Fail"; + message_block = + Strings::format("", to_string(test.result)); + break; + case BuildResult::EXCLUDED: + case BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES: + result_string = "Skip"; + message_block = Strings::format("", to_string(test.result)); + break; + case BuildResult::SUCCEEDED: result_string = "Pass"; break; + default: Checks::exit_fail(VCPKG_LINE_INFO); break; } std::string traits_block; @@ -187,13 +172,13 @@ namespace vcpkg::Commands::CI } m_xml += Strings::format(R"( %s%s)" - "\n", - test.name, - test.name, - test.time.as().count(), - result_string, - traits_block, - message_block); + "\n", + test.name, + test.name, + test.time.as().count(), + result_string, + traits_block, + message_block); } Optional m_assembly_run_datetime; @@ -203,7 +188,6 @@ namespace vcpkg::Commands::CI std::string m_xml; }; - struct UnknownCIPortsResults { std::vector unknown; @@ -212,11 +196,12 @@ namespace vcpkg::Commands::CI std::map abi_tag_map; }; - static std::unique_ptr find_unknown_ports_for_ci(const VcpkgPaths& paths, - const std::set& exclusions, - const Dependencies::PortFileProvider& provider, - const std::vector& fspecs, - const bool purge_tombstones) + static std::unique_ptr find_unknown_ports_for_ci( + const VcpkgPaths& paths, + const std::set& exclusions, + const Dependencies::PortFileProvider& provider, + const std::vector& fspecs, + const bool purge_tombstones) { auto ret = std::make_unique(); @@ -251,7 +236,7 @@ namespace vcpkg::Commands::CI { auto triplet = p->spec.triplet(); - const Build::BuildPackageConfig build_config { + const Build::BuildPackageConfig build_config{ *scf, triplet, paths.port_dir(p->spec), build_options, p->feature_list}; auto dependency_abis = @@ -297,7 +282,7 @@ namespace vcpkg::Commands::CI bool b_will_build = false; ret->features.emplace(p->spec, - std::vector {p->feature_list.begin(), p->feature_list.end()}); + std::vector{p->feature_list.begin(), p->feature_list.end()}); if (Util::Sets::contains(exclusions, p->spec.name())) { @@ -469,21 +454,27 @@ namespace vcpkg::Commands::CI for (auto&& result : summary.results) { split_specs->known.erase(result.spec); - xunitTestResults.add_test_results(result.spec.to_string(), result.build_result.code, result.timing, split_specs->abi_tag_map.at(result.spec)); + xunitTestResults.add_test_results(result.spec.to_string(), + result.build_result.code, + result.timing, + split_specs->abi_tag_map.at(result.spec)); } // Adding results for ports that were not built because they have known states for (auto&& port : split_specs->known) { - xunitTestResults.add_test_results(port.first.to_string(), port.second, Chrono::ElapsedTime{}, split_specs->abi_tag_map.at(port.first)); + xunitTestResults.add_test_results(port.first.to_string(), + port.second, + Chrono::ElapsedTime{}, + split_specs->abi_tag_map.at(port.first)); } all_known_results.emplace_back(std::move(split_specs->known)); abi_tag_map.insert(split_specs->abi_tag_map.begin(), split_specs->abi_tag_map.end()); - results.push_back({ triplet, std::move(summary)}); + results.push_back({triplet, std::move(summary)}); - xunitTestResults.collection_time( collection_time_elapsed ); + xunitTestResults.collection_time(collection_time_elapsed); } } xunitTestResults.assembly_time(timer.elapsed()); diff --git a/toolsrc/src/vcpkg/commands.create.cpp b/toolsrc/src/vcpkg/commands.create.cpp index a6f2c88384f..31bf97f3038 100644 --- a/toolsrc/src/vcpkg/commands.create.cpp +++ b/toolsrc/src/vcpkg/commands.create.cpp @@ -9,8 +9,7 @@ namespace vcpkg::Commands::Create { const CommandStructure COMMAND_STRUCTURE = { - Help::create_example_string( - R"###(create zlib2 http://zlib.net/zlib1211.zip "zlib1211-2.zip")###"), + Help::create_example_string(R"###(create zlib2 http://zlib.net/zlib1211.zip "zlib1211-2.zip")###"), 2, 3, {}, diff --git a/toolsrc/src/vcpkg/commands.dependinfo.cpp b/toolsrc/src/vcpkg/commands.dependinfo.cpp index 92ba15c1ff8..48a289fa5d0 100644 --- a/toolsrc/src/vcpkg/commands.dependinfo.cpp +++ b/toolsrc/src/vcpkg/commands.dependinfo.cpp @@ -16,7 +16,8 @@ namespace vcpkg::Commands::DependInfo constexpr std::array DEPEND_SWITCHES = {{ {OPTION_DOT, "Creates graph on basis of dot"}, {OPTION_DGML, "Creates graph on basis of dgml"}, - {OPTION_NO_RECURSE, "Computes only immediate dependencies of packages explicitly specified on the command-line"}, + {OPTION_NO_RECURSE, + "Computes only immediate dependencies of packages explicitly specified on the command-line"}, }}; const CommandStructure COMMAND_STRUCTURE = { diff --git a/toolsrc/src/vcpkg/commands.edit.cpp b/toolsrc/src/vcpkg/commands.edit.cpp index b2309aa41a4..98176b2b056 100644 --- a/toolsrc/src/vcpkg/commands.edit.cpp +++ b/toolsrc/src/vcpkg/commands.edit.cpp @@ -19,26 +19,16 @@ namespace vcpkg::Commands::Edit HKEY root; StringLiteral subkey; } REGKEYS[] = { - { - HKEY_LOCAL_MACHINE, - R"(SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{C26E74D1-022E-4238-8B9D-1E7564A36CC9}_is1)" - }, - { - HKEY_LOCAL_MACHINE, - R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1287CAD5-7C8D-410D-88B9-0D1EE4A83FF2}_is1)" - }, - { - HKEY_LOCAL_MACHINE, - R"(SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{F8A2A208-72B3-4D61-95FC-8A65D340689B}_is1)" - }, - { - HKEY_CURRENT_USER, - R"(Software\Microsoft\Windows\CurrentVersion\Uninstall\{771FD6B0-FA20-440A-A002-3B3BAC16DC50}_is1)" - }, - { - HKEY_LOCAL_MACHINE, - R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EA457B21-F73E-494C-ACAB-524FDE069978}_is1)" - }, + {HKEY_LOCAL_MACHINE, + R"(SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{C26E74D1-022E-4238-8B9D-1E7564A36CC9}_is1)"}, + {HKEY_LOCAL_MACHINE, + R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1287CAD5-7C8D-410D-88B9-0D1EE4A83FF2}_is1)"}, + {HKEY_LOCAL_MACHINE, + R"(SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{F8A2A208-72B3-4D61-95FC-8A65D340689B}_is1)"}, + {HKEY_CURRENT_USER, + R"(Software\Microsoft\Windows\CurrentVersion\Uninstall\{771FD6B0-FA20-440A-A002-3B3BAC16DC50}_is1)"}, + {HKEY_LOCAL_MACHINE, + R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EA457B21-F73E-494C-ACAB-524FDE069978}_is1)"}, }; for (auto&& keypath : REGKEYS) @@ -177,7 +167,8 @@ namespace vcpkg::Commands::Edit const std::vector from_registry = find_from_registry(); candidate_paths.insert(candidate_paths.end(), from_registry.cbegin(), from_registry.cend()); #elif defined(__APPLE__) - candidate_paths.push_back(fs::path{"/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code"}); + candidate_paths.push_back( + fs::path{"/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code"}); candidate_paths.push_back(fs::path{"/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"}); #elif defined(__linux__) candidate_paths.push_back(fs::path{"/usr/share/code/bin/code"}); diff --git a/toolsrc/src/vcpkg/commands.import.cpp b/toolsrc/src/vcpkg/commands.import.cpp index a2fd5d15d82..f03140fbdd7 100644 --- a/toolsrc/src/vcpkg/commands.import.cpp +++ b/toolsrc/src/vcpkg/commands.import.cpp @@ -93,8 +93,7 @@ namespace vcpkg::Commands::Import } const CommandStructure COMMAND_STRUCTURE = { - Help::create_example_string( - R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)"), + Help::create_example_string(R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)"), 3, 3, {}, diff --git a/toolsrc/src/vcpkg/commands.integrate.cpp b/toolsrc/src/vcpkg/commands.integrate.cpp index 026ab3b77cf..ef555a8440a 100644 --- a/toolsrc/src/vcpkg/commands.integrate.cpp +++ b/toolsrc/src/vcpkg/commands.integrate.cpp @@ -124,7 +124,7 @@ namespace vcpkg::Commands::Integrate static ElevationPromptChoice elevated_cmd_execute(const std::string& param) { - SHELLEXECUTEINFOW sh_ex_info {}; + SHELLEXECUTEINFOW sh_ex_info{}; sh_ex_info.cbSize = sizeof(sh_ex_info); sh_ex_info.fMask = SEE_MASK_NOCLOSEPROCESS; sh_ex_info.hwnd = nullptr; @@ -415,7 +415,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console static void integrate_bash(const VcpkgPaths& paths) { const auto home_path = System::get_environment_variable("HOME").value_or_exit(VCPKG_LINE_INFO); - const fs::path bashrc_path = fs::path {home_path} / ".bashrc"; + const fs::path bashrc_path = fs::path{home_path} / ".bashrc"; auto& fs = paths.get_filesystem(); const fs::path completion_script_path = paths.scripts / "vcpkg_completion.bash"; @@ -430,7 +430,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console for (auto&& line : bashrc_content) { std::smatch match; - if (std::regex_match(line, match, std::regex {R"###(^source.*scripts/vcpkg_completion.bash$)###"})) + if (std::regex_match(line, match, std::regex{R"###(^source.*scripts/vcpkg_completion.bash$)###"})) { matches.push_back(line); } @@ -439,11 +439,11 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console if (!matches.empty()) { System::printf("vcpkg bash completion is already imported to your %s file.\n" - "The following entries were found:\n" - " %s\n" - "Please make sure you have started a new bash shell for the changes to take effect.\n", - bashrc_path.u8string(), - Strings::join("\n ", matches)); + "The following entries were found:\n" + " %s\n" + "Please make sure you have started a new bash shell for the changes to take effect.\n", + bashrc_path.u8string(), + Strings::join("\n ", matches)); Checks::exit_success(VCPKG_LINE_INFO); } diff --git a/toolsrc/src/vcpkg/export.cpp b/toolsrc/src/vcpkg/export.cpp index f6a95b61fd3..433d7a1afb6 100644 --- a/toolsrc/src/vcpkg/export.cpp +++ b/toolsrc/src/vcpkg/export.cpp @@ -229,10 +229,10 @@ namespace vcpkg::Export { const std::vector integration_files_relative_to_root = { {".vcpkg-root"}, - {fs::path {"scripts"} / "buildsystems" / "msbuild" / "applocal.ps1"}, - {fs::path {"scripts"} / "buildsystems" / "msbuild" / "vcpkg.targets"}, - {fs::path {"scripts"} / "buildsystems" / "vcpkg.cmake"}, - {fs::path {"scripts"} / "cmake" / "vcpkg_get_windows_sdk.cmake"}, + {fs::path{"scripts"} / "buildsystems" / "msbuild" / "applocal.ps1"}, + {fs::path{"scripts"} / "buildsystems" / "msbuild" / "vcpkg.targets"}, + {fs::path{"scripts"} / "buildsystems" / "vcpkg.cmake"}, + {fs::path{"scripts"} / "cmake" / "vcpkg_get_windows_sdk.cmake"}, }; for (const fs::path& file : integration_files_relative_to_root) diff --git a/toolsrc/src/vcpkg/install.cpp b/toolsrc/src/vcpkg/install.cpp index 7fb304c17da..adab4249fdf 100644 --- a/toolsrc/src/vcpkg/install.cpp +++ b/toolsrc/src/vcpkg/install.cpp @@ -156,14 +156,15 @@ namespace vcpkg::Install const std::string name = t.pgh.package.displayname(); - for (const std::string &file : t.files) + for (const std::string& file : t.files) { output.emplace_back(file_pack{std::string(file, remove_chars), name}); } } - std::sort(output.begin(), output.end(), - [](const file_pack &lhs, const file_pack &rhs) { return lhs.first < rhs.first; }); + std::sort(output.begin(), output.end(), [](const file_pack& lhs, const file_pack& rhs) { + return lhs.first < rhs.first; + }); return output; } @@ -180,8 +181,7 @@ namespace vcpkg::Install } static SortedVector build_list_of_installed_files( - const std::vector& pgh_and_files, - const Triplet& triplet) + const std::vector& pgh_and_files, const Triplet& triplet) { const size_t installed_remove_char_count = triplet.canonical_name().size() + 1; // +1 for the slash std::vector installed_files = @@ -198,13 +198,12 @@ namespace vcpkg::Install const SortedVector package_files = build_list_of_package_files(paths.get_filesystem(), package_dir); - const SortedVector installed_files = - build_list_of_installed_files(pgh_and_files, triplet); + const SortedVector installed_files = build_list_of_installed_files(pgh_and_files, triplet); struct intersection_compare { - bool operator()(const std::string &lhs, const file_pack &rhs) { return lhs < rhs.first; } - bool operator()(const file_pack &lhs, const std::string &rhs) { return lhs.first < rhs; } + bool operator()(const std::string& lhs, const file_pack& rhs) { return lhs < rhs.first; } + bool operator()(const file_pack& lhs, const std::string& rhs) { return lhs.first < rhs; } }; std::vector intersection; @@ -216,11 +215,9 @@ namespace vcpkg::Install std::back_inserter(intersection), intersection_compare()); - std::sort(intersection.begin(), intersection.end(), - [](const file_pack &lhs, const file_pack &rhs) - { - return lhs.second < rhs.second; - }); + std::sort(intersection.begin(), intersection.end(), [](const file_pack& lhs, const file_pack& rhs) { + return lhs.second < rhs.second; + }); if (!intersection.empty()) { @@ -231,19 +228,13 @@ namespace vcpkg::Install bcf.core_paragraph.spec); auto i = intersection.begin(); - while (i != intersection.end()) { + while (i != intersection.end()) + { System::print2("Installed by ", i->second, "\n "); - auto next = std::find_if(i, intersection.end(), - [i](const auto &val) - { - return i->second != val.second; - }); + auto next = + std::find_if(i, intersection.end(), [i](const auto& val) { return i->second != val.second; }); - System::print2(Strings::join("\n ", i, next, - [](const file_pack &file) - { - return file.first; - })); + System::print2(Strings::join("\n ", i, next, [](const file_pack& file) { return file.first; })); System::print2("\n\n"); i = next; @@ -372,9 +363,8 @@ namespace vcpkg::Install auto& fs = paths.get_filesystem(); const fs::path download_dir = paths.downloads; std::error_code ec; - for(auto& p: fs.get_files_non_recursive(download_dir)) - if (!fs.is_directory(p)) - fs.remove(p); + for (auto& p : fs.get_files_non_recursive(download_dir)) + if (!fs.is_directory(p)) fs.remove(p); } return {code, std::move(bcf)}; diff --git a/toolsrc/src/vcpkg/packagespecparseresult.cpp b/toolsrc/src/vcpkg/packagespecparseresult.cpp index c5254f7bea1..ef078ea2841 100644 --- a/toolsrc/src/vcpkg/packagespecparseresult.cpp +++ b/toolsrc/src/vcpkg/packagespecparseresult.cpp @@ -19,8 +19,5 @@ namespace vcpkg } } - void to_string(std::string& out, PackageSpecParseResult p) - { - out.append(vcpkg::to_string(p).c_str()); - } + void to_string(std::string& out, PackageSpecParseResult p) { out.append(vcpkg::to_string(p).c_str()); } } diff --git a/toolsrc/src/vcpkg/paragraphs.cpp b/toolsrc/src/vcpkg/paragraphs.cpp index 431fad5ca43..21ef2c4d9c5 100644 --- a/toolsrc/src/vcpkg/paragraphs.cpp +++ b/toolsrc/src/vcpkg/paragraphs.cpp @@ -1,9 +1,9 @@ #include "pch.h" #include +#include #include #include -#include #include #include diff --git a/toolsrc/src/vcpkg/tools.cpp b/toolsrc/src/vcpkg/tools.cpp index 7232971c7f7..2fdfbe0f2b9 100644 --- a/toolsrc/src/vcpkg/tools.cpp +++ b/toolsrc/src/vcpkg/tools.cpp @@ -62,7 +62,7 @@ namespace vcpkg #if defined(_WIN32) || defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) static const std::string XML_VERSION = "2"; static const fs::path XML_PATH = paths.scripts / "vcpkgTools.xml"; - static const std::regex XML_VERSION_REGEX {R"###()###"}; + static const std::regex XML_VERSION_REGEX{R"###()###"}; static const std::string XML = paths.get_filesystem().read_contents(XML_PATH).value_or_exit(VCPKG_LINE_INFO); std::smatch match_xml_version; const bool has_xml_version = std::regex_search(XML.cbegin(), XML.cend(), match_xml_version, XML_VERSION_REGEX); @@ -78,7 +78,7 @@ namespace vcpkg XML_VERSION, match_xml_version[1]); - const std::regex tool_regex {Strings::format(R"###()###", tool, OS_STRING)}; + const std::regex tool_regex{Strings::format(R"###()###", tool, OS_STRING)}; std::smatch match_tool_entry; const bool has_tool_entry = std::regex_search(XML.cbegin(), XML.cend(), match_tool_entry, tool_regex); if (!has_tool_entry) @@ -109,13 +109,13 @@ namespace vcpkg const fs::path tool_dir_path = paths.tools / tool_dir_name; const fs::path exe_path = tool_dir_path / exe_relative_path; - return ToolData {*version.get(), - exe_path, - url, - paths.downloads / archive_name.value_or(exe_relative_path).to_string(), - archive_name.has_value(), - tool_dir_path, - sha512}; + return ToolData{*version.get(), + exe_path, + url, + paths.downloads / archive_name.value_or(exe_relative_path).to_string(), + archive_name.has_value(), + tool_dir_path, + sha512}; #endif } @@ -156,7 +156,7 @@ namespace vcpkg actual_version[2] >= expected_version[2]); if (!version_acceptable) continue; - return PathAndVersion {candidate, *version}; + return PathAndVersion{candidate, *version}; } return nullopt; diff --git a/toolsrc/src/vcpkg/userconfig.cpp b/toolsrc/src/vcpkg/userconfig.cpp index 4945fdaaaa2..a7c4e276552 100644 --- a/toolsrc/src/vcpkg/userconfig.cpp +++ b/toolsrc/src/vcpkg/userconfig.cpp @@ -39,10 +39,7 @@ namespace vcpkg #endif } - static fs::path get_config_path() - { - return get_user_dir() / "config"; - } + static fs::path get_config_path() { return get_user_dir() / "config"; } UserConfig UserConfig::try_read_data(const Files::Filesystem& fs) {