diff options
| author | Andrei Lebedev <lebdron@gmail.com> | 2019-06-12 08:25:07 +0300 |
|---|---|---|
| committer | Andrei Lebedev <lebdron@gmail.com> | 2019-06-12 08:25:07 +0300 |
| commit | 34d19da9ffd0571bf16190ec4a16a04bef265900 (patch) | |
| tree | 413690269c5f216194b9a0f72f0438b27ccfd68d /toolsrc/src | |
| parent | b395438c791ca9f78e383a1d571525eee785e67c (diff) | |
| parent | 59a8a9c6248ed230b19028a44484ae5f06db697d (diff) | |
| download | vcpkg-34d19da9ffd0571bf16190ec4a16a04bef265900.tar.gz vcpkg-34d19da9ffd0571bf16190ec4a16a04bef265900.zip | |
Merge branch 'master' into openssl-unix-dynamic
Diffstat (limited to 'toolsrc/src')
22 files changed, 205 insertions, 200 deletions
diff --git a/toolsrc/src/tests.arguments.cpp b/toolsrc/src/tests.arguments.cpp index c87281fa8..72bdbdb65 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<CommandSetting, 1> settings = { {{"--a", ""}} };
- CommandStructure cmdstruct = { "", 0, SIZE_MAX, {{}, settings }, nullptr };
+ std::array<CommandSetting, 1> settings = {{{"--a", ""}}};
+ CommandStructure cmdstruct = {"", 0, SIZE_MAX, {{}, settings}, nullptr};
std::vector<std::string> 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<CommandSwitch, 2> switches = { {{"--a", ""}, {"--c", ""}} };
- std::array<CommandSetting, 2> settings = { { {"--b", ""}, {"--d", ""}} };
+ std::array<CommandSwitch, 2> switches = {{{"--a", ""}, {"--c", ""}}};
+ std::array<CommandSetting, 2> settings = {{{"--b", ""}, {"--d", ""}}};
CommandStructure cmdstruct = {"", 0, SIZE_MAX, {switches, settings}, nullptr};
std::vector<std::string> t = {"--a", "--b=c"};
diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index 9102205d8..ab7586eeb 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 037cbdc14..69a916828 100644 --- a/toolsrc/src/vcpkg/archives.cpp +++ b/toolsrc/src/vcpkg/archives.cpp @@ -1,8 +1,8 @@ #include "pch.h" #include <vcpkg/archives.h> -#include <vcpkg/commands.h> #include <vcpkg/base/system.process.h> +#include <vcpkg/commands.h> namespace vcpkg::Archives { diff --git a/toolsrc/src/vcpkg/base/chrono.cpp b/toolsrc/src/vcpkg/base/chrono.cpp index 959ff90c8..86dc590f8 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<tm> 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<tm> 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<char, 80> date {}; + std::array<char, 80> 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 590c48ff5..218ff86b3 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 164394100..0396a2415 100644 --- a/toolsrc/src/vcpkg/base/files.cpp +++ b/toolsrc/src/vcpkg/base/files.cpp @@ -7,13 +7,18 @@ #include <vcpkg/base/system.process.h> #include <vcpkg/base/util.h> -#if defined(__linux__) +#if defined(__linux__) || defined(__APPLE__) #include <fcntl.h> -#include <sys/sendfile.h> +#include <string.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #endif +#if defined(__linux__) +#include <sys/sendfile.h> +#elif defined(__APPLE__) +#include <copyfile.h> +#endif namespace vcpkg::Files { @@ -166,7 +171,7 @@ namespace vcpkg::Files std::error_code& ec) override { this->rename(oldpath, newpath, ec); -#if defined(__linux__) +#if defined(__linux__) || defined(__APPLE__) if (ec) { auto dst = newpath; @@ -182,13 +187,25 @@ namespace vcpkg::Files return; } +#if defined(__linux__) off_t bytes = 0; struct stat info = {0}; fstat(i_fd, &info); auto written_bytes = sendfile(o_fd, i_fd, &bytes, info.st_size); +#elif defined(__APPLE__) + auto written_bytes = fcopyfile(i_fd, o_fd, 0, COPYFILE_ALL); +#endif + if (written_bytes == -1) + { + ec.assign(errno, std::generic_category()); + close(i_fd); + close(o_fd); + + return; + } + close(i_fd); close(o_fd); - if (written_bytes == -1) return; this->rename(dst, newpath, ec); if (ec) return; diff --git a/toolsrc/src/vcpkg/base/system.cpp b/toolsrc/src/vcpkg/base/system.cpp index 132c1f074..48a701bfa 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<CMakeVariable>& pass_variables) + const fs::path& cmake_script, + const std::vector<CMakeVariable>& 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<std::string, std::string>& extra_env) + int System::cmd_execute_clean(const ZStringView cmd_line, + const std::unordered_map<std::string, std::string>& 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 c5f145052..7bd6f467b 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -6,9 +6,9 @@ #include <vcpkg/base/hash.h>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/stringliteral.h>
+#include <vcpkg/base/system.debug.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/system.process.h>
-#include <vcpkg/base/system.debug.h>
#include <vcpkg/build.h>
#include <vcpkg/commands.h>
@@ -70,6 +70,7 @@ namespace vcpkg::Build::Command Build::AllowDownloads::YES,
Build::CleanBuildtrees::NO,
Build::CleanPackages::NO,
+ Build::CleanDownloads::NO,
Build::DownloadTool::BUILT_IN,
GlobalState::g_binary_caching ? Build::BinaryCaching::YES : Build::BinaryCaching::NO,
Build::FailOnTombstone::NO,
@@ -359,14 +360,13 @@ namespace vcpkg::Build const Toolset& toolset = paths.get_toolset(pre_build_info);
- std::vector<System::CMakeVariable> variables {
+ std::vector<System::CMakeVariable> 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)},
@@ -379,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())
@@ -483,14 +480,14 @@ namespace vcpkg::Build // the order of recursive_directory_iterator is undefined so save the names to sort
std::vector<fs::path> 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;
}
}
@@ -501,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.
@@ -511,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")});
}
}
@@ -601,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
}
@@ -729,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 10cb7d9fe..ff7e7a134 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<std::chrono::seconds>().count()); - m_xml += Strings::format( - R"(<assemblies>)" "\n" - R"( <assembly name="vcpkg" %s %s>)" "\n" - , datetime, time); + m_xml += Strings::format(R"(<assemblies>)" + "\n" + R"( <assembly name="vcpkg" %s %s>)" + "\n", + datetime, + time); } void xml_finish_assembly() { m_xml += " </assembly>\n" - "</assemblies>\n"; + "</assemblies>\n"; } void xml_start_collection(const XunitCollection& collection) { m_xml += Strings::format(R"( <collection name="%s" time="%lld">)" - "\n", - collection.name, - collection.time.as<std::chrono::seconds>().count()); - } - void xml_finish_collection() - { - m_xml += " </collection>\n"; + "\n", + collection.name, + collection.time.as<std::chrono::seconds>().count()); } + void xml_finish_collection() { m_xml += " </collection>\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("<failure><message><![CDATA[%s]]></message></failure>", to_string(test.result)); - break; - case BuildResult::EXCLUDED: - case BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES: - result_string = "Skip"; - message_block = Strings::format("<reason><![CDATA[%s]]></reason>", 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("<failure><message><![CDATA[%s]]></message></failure>", to_string(test.result)); + break; + case BuildResult::EXCLUDED: + case BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES: + result_string = "Skip"; + message_block = Strings::format("<reason><![CDATA[%s]]></reason>", 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"( <test name="%s" method="%s" time="%lld" result="%s">%s%s</test>)" - "\n", - test.name, - test.name, - test.time.as<std::chrono::seconds>().count(), - result_string, - traits_block, - message_block); + "\n", + test.name, + test.name, + test.time.as<std::chrono::seconds>().count(), + result_string, + traits_block, + message_block); } Optional<vcpkg::Chrono::CTime> m_assembly_run_datetime; @@ -203,7 +188,6 @@ namespace vcpkg::Commands::CI std::string m_xml; }; - struct UnknownCIPortsResults { std::vector<FullPackageSpec> unknown; @@ -212,11 +196,12 @@ namespace vcpkg::Commands::CI std::map<PackageSpec, std::string> abi_tag_map; }; - static std::unique_ptr<UnknownCIPortsResults> find_unknown_ports_for_ci(const VcpkgPaths& paths, - const std::set<std::string>& exclusions, - const Dependencies::PortFileProvider& provider, - const std::vector<FeatureSpec>& fspecs, - const bool purge_tombstones) + static std::unique_ptr<UnknownCIPortsResults> find_unknown_ports_for_ci( + const VcpkgPaths& paths, + const std::set<std::string>& exclusions, + const Dependencies::PortFileProvider& provider, + const std::vector<FeatureSpec>& fspecs, + const bool purge_tombstones) { auto ret = std::make_unique<UnknownCIPortsResults>(); @@ -229,6 +214,7 @@ namespace vcpkg::Commands::CI Build::AllowDownloads::YES, Build::CleanBuildtrees::YES, Build::CleanPackages::YES, + Build::CleanDownloads::NO, Build::DownloadTool::BUILT_IN, GlobalState::g_binary_caching ? Build::BinaryCaching::YES : Build::BinaryCaching::NO, Build::FailOnTombstone::YES, @@ -250,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 = @@ -296,7 +282,7 @@ namespace vcpkg::Commands::CI bool b_will_build = false; ret->features.emplace(p->spec, - std::vector<std::string> {p->feature_list.begin(), p->feature_list.end()}); + std::vector<std::string>{p->feature_list.begin(), p->feature_list.end()}); if (Util::Sets::contains(exclusions, p->spec.name())) { @@ -372,6 +358,7 @@ namespace vcpkg::Commands::CI Build::AllowDownloads::YES, Build::CleanBuildtrees::YES, Build::CleanPackages::YES, + Build::CleanDownloads::NO, Build::DownloadTool::BUILT_IN, GlobalState::g_binary_caching ? Build::BinaryCaching::YES : Build::BinaryCaching::NO, Build::FailOnTombstone::YES, @@ -467,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 a6f2c8838..31bf97f30 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 92ba15c1f..48a289fa5 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<CommandSwitch, 3> 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 b2309aa41..98176b2b0 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<fs::path> 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 a2fd5d15d..f03140fbd 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 026ab3b77..ef555a844 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/commands.upgrade.cpp b/toolsrc/src/vcpkg/commands.upgrade.cpp index 29627db3d..29815ca94 100644 --- a/toolsrc/src/vcpkg/commands.upgrade.cpp +++ b/toolsrc/src/vcpkg/commands.upgrade.cpp @@ -155,6 +155,7 @@ namespace vcpkg::Commands::Upgrade Build::AllowDownloads::YES, Build::CleanBuildtrees::NO, Build::CleanPackages::NO, + Build::CleanDownloads::NO, Build::DownloadTool::BUILT_IN, GlobalState::g_binary_caching ? Build::BinaryCaching::YES : Build::BinaryCaching::NO, Build::FailOnTombstone::NO, diff --git a/toolsrc/src/vcpkg/export.cpp b/toolsrc/src/vcpkg/export.cpp index 870d2c49e..433d7a1af 100644 --- a/toolsrc/src/vcpkg/export.cpp +++ b/toolsrc/src/vcpkg/export.cpp @@ -75,6 +75,7 @@ namespace vcpkg::Export Build::AllowDownloads::YES, Build::CleanBuildtrees::NO, Build::CleanPackages::NO, + Build::CleanDownloads::NO, Build::DownloadTool::BUILT_IN, Build::BinaryCaching::NO, Build::FailOnTombstone::NO, @@ -228,10 +229,10 @@ namespace vcpkg::Export { const std::vector<fs::path> 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 646e9bc2e..adab4249f 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<file_pack> build_list_of_installed_files( - const std::vector<StatusParagraphAndAssociatedFiles>& pgh_and_files, - const Triplet& triplet) + const std::vector<StatusParagraphAndAssociatedFiles>& pgh_and_files, const Triplet& triplet) { const size_t installed_remove_char_count = triplet.canonical_name().size() + 1; // +1 for the slash std::vector<file_pack> installed_files = @@ -198,13 +198,12 @@ namespace vcpkg::Install const SortedVector<std::string> package_files = build_list_of_package_files(paths.get_filesystem(), package_dir); - const SortedVector<file_pack> installed_files = - build_list_of_installed_files(pgh_and_files, triplet); + const SortedVector<file_pack> 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<file_pack> 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; - }); - - System::print2(Strings::join("\n ", i, next, - [](const file_pack &file) - { - return file.first; - })); + 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("\n\n"); i = next; @@ -367,6 +358,15 @@ namespace vcpkg::Install fs.remove_all(package_dir, ec); } + if (action.build_options.clean_downloads == Build::CleanDownloads::YES) + { + 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); + } + return {code, std::move(bcf)}; } @@ -463,14 +463,16 @@ namespace vcpkg::Install static constexpr StringLiteral OPTION_KEEP_GOING = "--keep-going"; static constexpr StringLiteral OPTION_XUNIT = "--x-xunit"; static constexpr StringLiteral OPTION_USE_ARIA2 = "--x-use-aria2"; + static constexpr StringLiteral OPTION_CLEAN_AFTER_BUILD = "--clean-after-build"; - static constexpr std::array<CommandSwitch, 6> INSTALL_SWITCHES = {{ + static constexpr std::array<CommandSwitch, 7> INSTALL_SWITCHES = {{ {OPTION_DRY_RUN, "Do not actually build or install"}, {OPTION_USE_HEAD_VERSION, "Install the libraries on the command line using the latest upstream sources"}, {OPTION_NO_DOWNLOADS, "Do not download new sources"}, {OPTION_RECURSE, "Allow removal of packages as part of installation"}, {OPTION_KEEP_GOING, "Continue installing packages on failure"}, {OPTION_USE_ARIA2, "Use aria2 to perform download tasks"}, + {OPTION_CLEAN_AFTER_BUILD, "Clean buildtrees, packages and downloads after building each package"}, }}; static constexpr std::array<CommandSetting, 1> INSTALL_SETTINGS = {{ {OPTION_XUNIT, "File to output results in XUnit format (Internal use)"}, @@ -531,7 +533,9 @@ namespace vcpkg::Install while (next != last) { auto match = *next; - library_targets[find_package_name].push_back(match[1]); + auto& targets = library_targets[find_package_name]; + if (std::find(targets.cbegin(), targets.cend(), match[1]) == targets.cend()) + targets.push_back(match[1]); ++next; } } @@ -621,6 +625,7 @@ namespace vcpkg::Install const bool no_downloads = Util::Sets::contains(options.switches, (OPTION_NO_DOWNLOADS)); const bool is_recursive = Util::Sets::contains(options.switches, (OPTION_RECURSE)); const bool use_aria2 = Util::Sets::contains(options.switches, (OPTION_USE_ARIA2)); + const bool clean_after_build = Util::Sets::contains(options.switches, (OPTION_CLEAN_AFTER_BUILD)); const KeepGoing keep_going = to_keep_going(Util::Sets::contains(options.switches, OPTION_KEEP_GOING)); // create the plan @@ -632,8 +637,9 @@ namespace vcpkg::Install const Build::BuildPackageOptions install_plan_options = { Util::Enum::to_enum<Build::UseHeadVersion>(use_head_version), Util::Enum::to_enum<Build::AllowDownloads>(!no_downloads), - Build::CleanBuildtrees::NO, - Build::CleanPackages::NO, + clean_after_build ? Build::CleanBuildtrees::YES : Build::CleanBuildtrees::NO, + clean_after_build ? Build::CleanPackages::YES : Build::CleanPackages::NO, + clean_after_build ? Build::CleanDownloads::YES : Build::CleanDownloads::NO, download_tool, GlobalState::g_binary_caching ? Build::BinaryCaching::YES : Build::BinaryCaching::NO, Build::FailOnTombstone::NO, diff --git a/toolsrc/src/vcpkg/packagespecparseresult.cpp b/toolsrc/src/vcpkg/packagespecparseresult.cpp index c5254f7be..ef078ea28 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 431fad5ca..21ef2c4d9 100644 --- a/toolsrc/src/vcpkg/paragraphs.cpp +++ b/toolsrc/src/vcpkg/paragraphs.cpp @@ -1,9 +1,9 @@ #include "pch.h" #include <vcpkg/base/files.h> +#include <vcpkg/base/system.debug.h> #include <vcpkg/base/system.print.h> #include <vcpkg/base/util.h> -#include <vcpkg/base/system.debug.h> #include <vcpkg/paragraphparseresult.h> #include <vcpkg/paragraphs.h> diff --git a/toolsrc/src/vcpkg/sourceparagraph.cpp b/toolsrc/src/vcpkg/sourceparagraph.cpp index b495c5f1d..9bc59cbe7 100644 --- a/toolsrc/src/vcpkg/sourceparagraph.cpp +++ b/toolsrc/src/vcpkg/sourceparagraph.cpp @@ -24,6 +24,7 @@ namespace vcpkg static const std::string SOURCE = "Source"; static const std::string SUPPORTS = "Supports"; static const std::string VERSION = "Version"; + static const std::string HOMEPAGE = "Homepage"; } static Span<const std::string> get_list_of_valid_fields() @@ -34,6 +35,7 @@ namespace vcpkg SourceParagraphFields::DESCRIPTION, SourceParagraphFields::MAINTAINER, SourceParagraphFields::BUILD_DEPENDS, + SourceParagraphFields::HOMEPAGE, }; return valid_fields; @@ -107,6 +109,7 @@ namespace vcpkg spgh->description = parser.optional_field(SourceParagraphFields::DESCRIPTION); spgh->maintainer = parser.optional_field(SourceParagraphFields::MAINTAINER); + spgh->homepage = parser.optional_field(SourceParagraphFields::HOMEPAGE); spgh->depends = expand_qualified_dependencies( parse_comma_list(parser.optional_field(SourceParagraphFields::BUILD_DEPENDS))); spgh->supports = parse_comma_list(parser.optional_field(SourceParagraphFields::SUPPORTS)); diff --git a/toolsrc/src/vcpkg/tools.cpp b/toolsrc/src/vcpkg/tools.cpp index 7232971c7..2fdfbe0f2 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"###(<tools[\s]+version="([^"]+)">)###"}; + static const std::regex XML_VERSION_REGEX{R"###(<tools[\s]+version="([^"]+)">)###"}; 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[\s]+name="%s"[\s]+os="%s">)###", tool, OS_STRING)}; + const std::regex tool_regex{Strings::format(R"###(<tool[\s]+name="%s"[\s]+os="%s">)###", 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 4945fdaaa..a7c4e2765 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) { |
