[vcpkg] Apply clang format (#6826)

This commit is contained in:
Robert Schumacher 2019-06-08 18:31:58 -07:00 committed by GitHub
parent 2ca3476149
commit 8045248372
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 166 additions and 203 deletions

View File

@ -56,8 +56,8 @@ namespace vcpkg::Chrono
static Optional<CTime> get_current_date_time(); static Optional<CTime> get_current_date_time();
static Optional<CTime> parse(CStringView str); static Optional<CTime> parse(CStringView str);
constexpr CTime() noexcept : m_tm {0} {} constexpr CTime() noexcept : m_tm{0} {}
explicit constexpr CTime(tm t) noexcept : m_tm {t} {} explicit constexpr CTime(tm t) noexcept : m_tm{t} {}
CTime add_hours(const int hours) const; CTime add_hours(const int hours) const;

View File

@ -43,7 +43,7 @@ namespace vcpkg::Strings::details
t.to_string(into); t.to_string(into);
} }
template<class T, class=void, class = decltype(to_string(std::declval<std::string&>(), std::declval<const T&>()))> template<class T, class = void, class = decltype(to_string(std::declval<std::string&>(), std::declval<const T&>()))>
void append_internal(std::string& into, const T& t) void append_internal(std::string& into, const T& t)
{ {
to_string(into, t); to_string(into, t);
@ -66,7 +66,8 @@ namespace vcpkg::Strings
} }
template<class... Args> template<class... Args>
[[nodiscard]] std::string concat(const Args&... args) { [[nodiscard]] std::string concat(const Args&... args)
{
std::string ret; std::string ret;
append(ret, args...); append(ret, args...);
return ret; return ret;
@ -113,8 +114,7 @@ namespace vcpkg::Strings
bool starts_with(StringView s, StringView pattern); bool starts_with(StringView s, StringView pattern);
template<class InputIterator, class Transformer> template<class InputIterator, class Transformer>
std::string join(const char* delimiter, InputIterator begin, InputIterator end, std::string join(const char* delimiter, InputIterator begin, InputIterator end, Transformer transformer)
Transformer transformer)
{ {
if (begin == end) if (begin == end)
{ {
@ -145,8 +145,7 @@ namespace vcpkg::Strings
std::string join(const char* delimiter, InputIterator begin, InputIterator end) std::string join(const char* delimiter, InputIterator begin, InputIterator end)
{ {
using Element = decltype(*begin); using Element = decltype(*begin);
return join(delimiter, begin, end, return join(delimiter, begin, end, [](const Element& x) -> const Element& { return x; });
[](const Element& x) -> const Element& { return x; });
} }
template<class Container> template<class Container>

View File

@ -33,8 +33,8 @@ namespace UnitTest1
TEST_METHOD(create_from_arg_sequence_valued_options) TEST_METHOD(create_from_arg_sequence_valued_options)
{ {
std::array<CommandSetting, 1> settings = { {{"--a", ""}} }; std::array<CommandSetting, 1> settings = {{{"--a", ""}}};
CommandStructure cmdstruct = { "", 0, SIZE_MAX, {{}, settings }, nullptr }; CommandStructure cmdstruct = {"", 0, SIZE_MAX, {{}, settings}, nullptr};
std::vector<std::string> t = {"--a=b", "command", "argument"}; std::vector<std::string> t = {"--a=b", "command", "argument"};
auto v = VcpkgCmdArguments::create_from_arg_sequence(t.data(), t.data() + t.size()); 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) TEST_METHOD(create_from_arg_sequence_valued_options2)
{ {
std::array<CommandSwitch, 2> switches = { {{"--a", ""}, {"--c", ""}} }; std::array<CommandSwitch, 2> switches = {{{"--a", ""}, {"--c", ""}}};
std::array<CommandSetting, 2> settings = { { {"--b", ""}, {"--d", ""}} }; std::array<CommandSetting, 2> settings = {{{"--b", ""}, {"--d", ""}}};
CommandStructure cmdstruct = {"", 0, SIZE_MAX, {switches, settings}, nullptr}; CommandStructure cmdstruct = {"", 0, SIZE_MAX, {switches, settings}, nullptr};
std::vector<std::string> t = {"--a", "--b=c"}; std::vector<std::string> t = {"--a", "--b=c"};

View File

@ -388,6 +388,6 @@ int main(const int argc, const char* const* const argv)
} }
fflush(stdout); 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); Checks::exit_fail(VCPKG_LINE_INFO);
} }

View File

@ -1,8 +1,8 @@
#include "pch.h" #include "pch.h"
#include <vcpkg/archives.h> #include <vcpkg/archives.h>
#include <vcpkg/commands.h>
#include <vcpkg/base/system.process.h> #include <vcpkg/base/system.process.h>
#include <vcpkg/commands.h>
namespace vcpkg::Archives namespace vcpkg::Archives
{ {

View File

@ -22,7 +22,7 @@ namespace vcpkg::Chrono
static tm to_local_time(const std::time_t& t) static tm to_local_time(const std::time_t& t)
{ {
tm parts {}; tm parts{};
#if defined(_WIN32) #if defined(_WIN32)
localtime_s(&parts, &t); localtime_s(&parts, &t);
#else #else
@ -33,7 +33,7 @@ namespace vcpkg::Chrono
static Optional<tm> to_utc_time(const std::time_t& t) static Optional<tm> to_utc_time(const std::time_t& t)
{ {
tm parts {}; tm parts{};
#if defined(_WIN32) #if defined(_WIN32)
const errno_t err = gmtime_s(&parts, &t); const errno_t err = gmtime_s(&parts, &t);
if (err) if (err)
@ -127,7 +127,7 @@ namespace vcpkg::Chrono
const Optional<tm> opt = to_utc_time(ct); const Optional<tm> opt = to_utc_time(ct);
if (auto p_tm = opt.get()) if (auto p_tm = opt.get())
{ {
return CTime {*p_tm}; return CTime{*p_tm};
} }
return nullopt; return nullopt;
@ -160,11 +160,11 @@ namespace vcpkg::Chrono
return ret; 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::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); strftime(&date[0], date.size(), "%Y-%m-%dT%H:%M:%S.0Z", &m_tm);
return &date[0]; return &date[0];
} }

View File

@ -44,18 +44,20 @@ namespace vcpkg::Downloads
Checks::check_exit(VCPKG_LINE_INFO, hSession, "WinHttpOpen() failed: %d", GetLastError()); Checks::check_exit(VCPKG_LINE_INFO, hSession, "WinHttpOpen() failed: %d", GetLastError());
// Win7 IE Proxy fallback // Win7 IE Proxy fallback
if (IsWindows7OrGreater() && !IsWindows8Point1OrGreater()) { if (IsWindows7OrGreater() && !IsWindows8Point1OrGreater())
{
// First check if any proxy has been found automatically // First check if any proxy has been found automatically
WINHTTP_PROXY_INFO proxyInfo; WINHTTP_PROXY_INFO proxyInfo;
DWORD proxyInfoSize = sizeof(WINHTTP_PROXY_INFO); DWORD proxyInfoSize = sizeof(WINHTTP_PROXY_INFO);
auto noProxyFound = auto noProxyFound = !WinHttpQueryOption(hSession, WINHTTP_OPTION_PROXY, &proxyInfo, &proxyInfoSize) ||
!WinHttpQueryOption(hSession, WINHTTP_OPTION_PROXY, &proxyInfo, &proxyInfoSize) proxyInfo.dwAccessType == WINHTTP_ACCESS_TYPE_NO_PROXY;
|| proxyInfo.dwAccessType == WINHTTP_ACCESS_TYPE_NO_PROXY;
// If no proxy was found automatically, use IE's proxy settings, if any
// If no proxy was found automatically, use IE's proxy settings, if any if (noProxyFound)
if (noProxyFound) { {
WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ieProxy; WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ieProxy;
if (WinHttpGetIEProxyConfigForCurrentUser(&ieProxy) && ieProxy.lpszProxy != nullptr) { if (WinHttpGetIEProxyConfigForCurrentUser(&ieProxy) && ieProxy.lpszProxy != nullptr)
{
WINHTTP_PROXY_INFO proxy; WINHTTP_PROXY_INFO proxy;
proxy.dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY; proxy.dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
proxy.lpszProxy = ieProxy.lpszProxy; proxy.lpszProxy = ieProxy.lpszProxy;

View File

@ -9,10 +9,10 @@
#if defined(__linux__) || defined(__APPLE__) #if defined(__linux__) || defined(__APPLE__)
#include <fcntl.h> #include <fcntl.h>
#include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <string.h>
#endif #endif
#if defined(__linux__) #if defined(__linux__)
#include <sys/sendfile.h> #include <sys/sendfile.h>

View File

@ -177,8 +177,8 @@ namespace vcpkg
} }
std::string System::make_cmake_cmd(const fs::path& cmake_exe, std::string System::make_cmake_cmd(const fs::path& cmake_exe,
const fs::path& cmake_script, const fs::path& cmake_script,
const std::vector<CMakeVariable>& pass_variables) const std::vector<CMakeVariable>& pass_variables)
{ {
const std::string cmd_cmake_pass_variables = Strings::join(" ", pass_variables, [](auto&& v) { return v.s; }); const std::string cmd_cmake_pass_variables = Strings::join(" ", pass_variables, [](auto&& v) { return v.s; });
return Strings::format( return Strings::format(
@ -345,7 +345,8 @@ namespace vcpkg
} }
#endif #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(); auto timer = Chrono::ElapsedTimer::create_started();
#if defined(_WIN32) #if defined(_WIN32)

View File

@ -6,9 +6,9 @@
#include <vcpkg/base/hash.h> #include <vcpkg/base/hash.h>
#include <vcpkg/base/optional.h> #include <vcpkg/base/optional.h>
#include <vcpkg/base/stringliteral.h> #include <vcpkg/base/stringliteral.h>
#include <vcpkg/base/system.debug.h>
#include <vcpkg/base/system.print.h> #include <vcpkg/base/system.print.h>
#include <vcpkg/base/system.process.h> #include <vcpkg/base/system.process.h>
#include <vcpkg/base/system.debug.h>
#include <vcpkg/build.h> #include <vcpkg/build.h>
#include <vcpkg/commands.h> #include <vcpkg/commands.h>
@ -360,14 +360,13 @@ namespace vcpkg::Build
const Toolset& toolset = paths.get_toolset(pre_build_info); const Toolset& toolset = paths.get_toolset(pre_build_info);
std::vector<System::CMakeVariable> variables { std::vector<System::CMakeVariable> variables{
{"CMD", "BUILD"}, {"CMD", "BUILD"},
{"PORT", config.scf.core_paragraph->name}, {"PORT", config.scf.core_paragraph->name},
{"CURRENT_PORT_DIR", config.port_dir}, {"CURRENT_PORT_DIR", config.port_dir},
{"TARGET_TRIPLET", spec.triplet().canonical_name()}, {"TARGET_TRIPLET", spec.triplet().canonical_name()},
{"VCPKG_PLATFORM_TOOLSET", toolset.version.c_str()}, {"VCPKG_PLATFORM_TOOLSET", toolset.version.c_str()},
{"VCPKG_USE_HEAD_VERSION", {"VCPKG_USE_HEAD_VERSION", Util::Enum::to_bool(config.build_package_options.use_head_version) ? "1" : "0"},
Util::Enum::to_bool(config.build_package_options.use_head_version) ? "1" : "0"},
{"DOWNLOADS", paths.downloads}, {"DOWNLOADS", paths.downloads},
{"_VCPKG_NO_DOWNLOADS", !Util::Enum::to_bool(config.build_package_options.allow_downloads) ? "1" : "0"}, {"_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)}, {"_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}); variables.push_back({"GIT", git_exe_path});
} }
const std::string cmd_launch_cmake = System::make_cmake_cmd( const std::string cmd_launch_cmake = System::make_cmake_cmd(cmake_exe_path, paths.ports_cmake, variables);
cmake_exe_path,
paths.ports_cmake,
variables);
auto command = make_build_env_cmd(pre_build_info, toolset); auto command = make_build_env_cmd(pre_build_info, toolset);
if (!command.empty()) if (!command.empty())
@ -484,14 +480,14 @@ namespace vcpkg::Build
// the order of recursive_directory_iterator is undefined so save the names to sort // the order of recursive_directory_iterator is undefined so save the names to sort
std::vector<fs::path> port_files; 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))) if (fs::is_regular_file(status(port_file)))
{ {
port_files.push_back(port_file); port_files.push_back(port_file);
if (port_files.size() > max_port_file_count) 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; break;
} }
} }
@ -502,7 +498,7 @@ namespace vcpkg::Build
std::sort(port_files.begin(), port_files.end()); std::sort(port_files.begin(), port_files.end());
int counter = 0; 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, // 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. // 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"); 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( System::cmd_execute_clean(Strings::format(
R"("%s" a "%s" "%s\*" >nul)", seven_zip_exe.u8string(), destination.u8string(), source.u8string())); R"("%s" a "%s" "%s\*" >nul)", seven_zip_exe.u8string(), destination.u8string(), source.u8string()));
#else #else
System::cmd_execute_clean(Strings::format( System::cmd_execute_clean(
R"(cd '%s' && zip --quiet -r '%s' *)", source.u8string(), destination.u8string())); Strings::format(R"(cd '%s' && zip --quiet -r '%s' *)", source.u8string(), destination.u8string()));
#endif #endif
} }
@ -730,7 +726,7 @@ namespace vcpkg::Build
const auto tmp_failure_zip = paths.buildtrees / spec.name() / "failure_logs.zip"; const auto tmp_failure_zip = paths.buildtrees / spec.name() / "failure_logs.zip";
fs.create_directories(tmp_log_path_destination, ec); 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") if (log_file.path().extension() == ".log")
{ {

View File

@ -55,27 +55,20 @@ namespace vcpkg::Commands::CI
struct XunitTestResults struct XunitTestResults
{ {
public: 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(); m_collections.back().tests.push_back({spec, build_result, elapsed_time, abi_tag});
}
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 });
} }
// Starting a new test collection // Starting a new test collection
void push_collection( const std::string& name) void push_collection(const std::string& name) { m_collections.push_back({name}); }
{
m_collections.push_back({name});
}
void collection_time(const vcpkg::Chrono::ElapsedTime& time) void collection_time(const vcpkg::Chrono::ElapsedTime& time) { m_collections.back().time = time; }
{
m_collections.back().time = time;
}
const std::string& build_xml() const std::string& build_xml()
{ {
@ -96,13 +89,9 @@ namespace vcpkg::Commands::CI
return m_xml; return m_xml;
} }
void assembly_time(const vcpkg::Chrono::ElapsedTime& assembly_time) void assembly_time(const vcpkg::Chrono::ElapsedTime& assembly_time) { m_assembly_time = assembly_time; }
{
m_assembly_time = assembly_time;
}
private: private:
struct XunitTest struct XunitTest
{ {
std::string name; std::string name;
@ -126,34 +115,33 @@ namespace vcpkg::Commands::CI
auto rawDateTime = m_assembly_run_datetime.get()->to_string(); auto rawDateTime = m_assembly_run_datetime.get()->to_string();
// The expected format is "yyyy-mm-ddThh:mm:ss.0Z" // The expected format is "yyyy-mm-ddThh:mm:ss.0Z"
// 0123456789012345678901 // 0123456789012345678901
datetime = Strings::format(R"(run-date="%s" run-time="%s")", datetime = Strings::format(
rawDateTime.substr(0, 10), rawDateTime.substr(11, 8)); 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()); std::string time = Strings::format(R"(time="%lld")", m_assembly_time.as<std::chrono::seconds>().count());
m_xml += Strings::format( m_xml += Strings::format(R"(<assemblies>)"
R"(<assemblies>)" "\n" "\n"
R"( <assembly name="vcpkg" %s %s>)" "\n" R"( <assembly name="vcpkg" %s %s>)"
, datetime, time); "\n",
datetime,
time);
} }
void xml_finish_assembly() void xml_finish_assembly()
{ {
m_xml += " </assembly>\n" m_xml += " </assembly>\n"
"</assemblies>\n"; "</assemblies>\n";
} }
void xml_start_collection(const XunitCollection& collection) void xml_start_collection(const XunitCollection& collection)
{ {
m_xml += Strings::format(R"( <collection name="%s" time="%lld">)" m_xml += Strings::format(R"( <collection name="%s" time="%lld">)"
"\n", "\n",
collection.name, collection.name,
collection.time.as<std::chrono::seconds>().count()); collection.time.as<std::chrono::seconds>().count());
}
void xml_finish_collection()
{
m_xml += " </collection>\n";
} }
void xml_finish_collection() { m_xml += " </collection>\n"; }
void xml_test(const XunitTest& test) void xml_test(const XunitTest& test)
{ {
@ -161,23 +149,20 @@ namespace vcpkg::Commands::CI
const char* result_string = ""; const char* result_string = "";
switch (test.result) switch (test.result)
{ {
case BuildResult::POST_BUILD_CHECKS_FAILED: case BuildResult::POST_BUILD_CHECKS_FAILED:
case BuildResult::FILE_CONFLICTS: case BuildResult::FILE_CONFLICTS:
case BuildResult::BUILD_FAILED: case BuildResult::BUILD_FAILED:
result_string = "Fail"; result_string = "Fail";
message_block = Strings::format("<failure><message><![CDATA[%s]]></message></failure>", to_string(test.result)); message_block =
break; Strings::format("<failure><message><![CDATA[%s]]></message></failure>", to_string(test.result));
case BuildResult::EXCLUDED: break;
case BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES: case BuildResult::EXCLUDED:
result_string = "Skip"; case BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES:
message_block = Strings::format("<reason><![CDATA[%s]]></reason>", to_string(test.result)); result_string = "Skip";
break; message_block = Strings::format("<reason><![CDATA[%s]]></reason>", to_string(test.result));
case BuildResult::SUCCEEDED: break;
result_string = "Pass"; case BuildResult::SUCCEEDED: result_string = "Pass"; break;
break; default: Checks::exit_fail(VCPKG_LINE_INFO); break;
default:
Checks::exit_fail(VCPKG_LINE_INFO);
break;
} }
std::string traits_block; 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>)" m_xml += Strings::format(R"( <test name="%s" method="%s" time="%lld" result="%s">%s%s</test>)"
"\n", "\n",
test.name, test.name,
test.name, test.name,
test.time.as<std::chrono::seconds>().count(), test.time.as<std::chrono::seconds>().count(),
result_string, result_string,
traits_block, traits_block,
message_block); message_block);
} }
Optional<vcpkg::Chrono::CTime> m_assembly_run_datetime; Optional<vcpkg::Chrono::CTime> m_assembly_run_datetime;
@ -203,7 +188,6 @@ namespace vcpkg::Commands::CI
std::string m_xml; std::string m_xml;
}; };
struct UnknownCIPortsResults struct UnknownCIPortsResults
{ {
std::vector<FullPackageSpec> unknown; std::vector<FullPackageSpec> unknown;
@ -212,11 +196,12 @@ namespace vcpkg::Commands::CI
std::map<PackageSpec, std::string> abi_tag_map; std::map<PackageSpec, std::string> abi_tag_map;
}; };
static std::unique_ptr<UnknownCIPortsResults> find_unknown_ports_for_ci(const VcpkgPaths& paths, static std::unique_ptr<UnknownCIPortsResults> find_unknown_ports_for_ci(
const std::set<std::string>& exclusions, const VcpkgPaths& paths,
const Dependencies::PortFileProvider& provider, const std::set<std::string>& exclusions,
const std::vector<FeatureSpec>& fspecs, const Dependencies::PortFileProvider& provider,
const bool purge_tombstones) const std::vector<FeatureSpec>& fspecs,
const bool purge_tombstones)
{ {
auto ret = std::make_unique<UnknownCIPortsResults>(); auto ret = std::make_unique<UnknownCIPortsResults>();
@ -251,7 +236,7 @@ namespace vcpkg::Commands::CI
{ {
auto triplet = p->spec.triplet(); 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}; *scf, triplet, paths.port_dir(p->spec), build_options, p->feature_list};
auto dependency_abis = auto dependency_abis =
@ -297,7 +282,7 @@ namespace vcpkg::Commands::CI
bool b_will_build = false; bool b_will_build = false;
ret->features.emplace(p->spec, 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())) if (Util::Sets::contains(exclusions, p->spec.name()))
{ {
@ -469,21 +454,27 @@ namespace vcpkg::Commands::CI
for (auto&& result : summary.results) for (auto&& result : summary.results)
{ {
split_specs->known.erase(result.spec); 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 // Adding results for ports that were not built because they have known states
for (auto&& port : split_specs->known) 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)); 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()); 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()); xunitTestResults.assembly_time(timer.elapsed());

View File

@ -9,8 +9,7 @@
namespace vcpkg::Commands::Create namespace vcpkg::Commands::Create
{ {
const CommandStructure COMMAND_STRUCTURE = { const CommandStructure COMMAND_STRUCTURE = {
Help::create_example_string( Help::create_example_string(R"###(create zlib2 http://zlib.net/zlib1211.zip "zlib1211-2.zip")###"),
R"###(create zlib2 http://zlib.net/zlib1211.zip "zlib1211-2.zip")###"),
2, 2,
3, 3,
{}, {},

View File

@ -16,7 +16,8 @@ namespace vcpkg::Commands::DependInfo
constexpr std::array<CommandSwitch, 3> DEPEND_SWITCHES = {{ constexpr std::array<CommandSwitch, 3> DEPEND_SWITCHES = {{
{OPTION_DOT, "Creates graph on basis of dot"}, {OPTION_DOT, "Creates graph on basis of dot"},
{OPTION_DGML, "Creates graph on basis of dgml"}, {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 = { const CommandStructure COMMAND_STRUCTURE = {

View File

@ -19,26 +19,16 @@ namespace vcpkg::Commands::Edit
HKEY root; HKEY root;
StringLiteral subkey; StringLiteral subkey;
} REGKEYS[] = { } REGKEYS[] = {
{ {HKEY_LOCAL_MACHINE,
HKEY_LOCAL_MACHINE, R"(SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{C26E74D1-022E-4238-8B9D-1E7564A36CC9}_is1)"},
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,
HKEY_LOCAL_MACHINE, R"(SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{F8A2A208-72B3-4D61-95FC-8A65D340689B}_is1)"},
R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1287CAD5-7C8D-410D-88B9-0D1EE4A83FF2}_is1)" {HKEY_CURRENT_USER,
}, R"(Software\Microsoft\Windows\CurrentVersion\Uninstall\{771FD6B0-FA20-440A-A002-3B3BAC16DC50}_is1)"},
{ {HKEY_LOCAL_MACHINE,
HKEY_LOCAL_MACHINE, R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EA457B21-F73E-494C-ACAB-524FDE069978}_is1)"},
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) for (auto&& keypath : REGKEYS)
@ -177,7 +167,8 @@ namespace vcpkg::Commands::Edit
const std::vector<fs::path> from_registry = find_from_registry(); const std::vector<fs::path> from_registry = find_from_registry();
candidate_paths.insert(candidate_paths.end(), from_registry.cbegin(), from_registry.cend()); candidate_paths.insert(candidate_paths.end(), from_registry.cbegin(), from_registry.cend());
#elif defined(__APPLE__) #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"}); candidate_paths.push_back(fs::path{"/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"});
#elif defined(__linux__) #elif defined(__linux__)
candidate_paths.push_back(fs::path{"/usr/share/code/bin/code"}); candidate_paths.push_back(fs::path{"/usr/share/code/bin/code"});

View File

@ -93,8 +93,7 @@ namespace vcpkg::Commands::Import
} }
const CommandStructure COMMAND_STRUCTURE = { const CommandStructure COMMAND_STRUCTURE = {
Help::create_example_string( Help::create_example_string(R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)"),
R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)"),
3, 3,
3, 3,
{}, {},

View File

@ -124,7 +124,7 @@ namespace vcpkg::Commands::Integrate
static ElevationPromptChoice elevated_cmd_execute(const std::string& param) 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.cbSize = sizeof(sh_ex_info);
sh_ex_info.fMask = SEE_MASK_NOCLOSEPROCESS; sh_ex_info.fMask = SEE_MASK_NOCLOSEPROCESS;
sh_ex_info.hwnd = nullptr; 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) static void integrate_bash(const VcpkgPaths& paths)
{ {
const auto home_path = System::get_environment_variable("HOME").value_or_exit(VCPKG_LINE_INFO); 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(); auto& fs = paths.get_filesystem();
const fs::path completion_script_path = paths.scripts / "vcpkg_completion.bash"; 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) for (auto&& line : bashrc_content)
{ {
std::smatch match; 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); matches.push_back(line);
} }
@ -439,11 +439,11 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console
if (!matches.empty()) if (!matches.empty())
{ {
System::printf("vcpkg bash completion is already imported to your %s file.\n" System::printf("vcpkg bash completion is already imported to your %s file.\n"
"The following entries were found:\n" "The following entries were found:\n"
" %s\n" " %s\n"
"Please make sure you have started a new bash shell for the changes to take effect.\n", "Please make sure you have started a new bash shell for the changes to take effect.\n",
bashrc_path.u8string(), bashrc_path.u8string(),
Strings::join("\n ", matches)); Strings::join("\n ", matches));
Checks::exit_success(VCPKG_LINE_INFO); Checks::exit_success(VCPKG_LINE_INFO);
} }

View File

@ -229,10 +229,10 @@ namespace vcpkg::Export
{ {
const std::vector<fs::path> integration_files_relative_to_root = { const std::vector<fs::path> integration_files_relative_to_root = {
{".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" / "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"},
}; };
for (const fs::path& file : integration_files_relative_to_root) for (const fs::path& file : integration_files_relative_to_root)

View File

@ -156,14 +156,15 @@ namespace vcpkg::Install
const std::string name = t.pgh.package.displayname(); 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}); output.emplace_back(file_pack{std::string(file, remove_chars), name});
} }
} }
std::sort(output.begin(), output.end(), std::sort(output.begin(), output.end(), [](const file_pack& lhs, const file_pack& rhs) {
[](const file_pack &lhs, const file_pack &rhs) { return lhs.first < rhs.first; }); return lhs.first < rhs.first;
});
return output; return output;
} }
@ -180,8 +181,7 @@ namespace vcpkg::Install
} }
static SortedVector<file_pack> build_list_of_installed_files( static SortedVector<file_pack> build_list_of_installed_files(
const std::vector<StatusParagraphAndAssociatedFiles>& pgh_and_files, const std::vector<StatusParagraphAndAssociatedFiles>& pgh_and_files, const Triplet& triplet)
const Triplet& triplet)
{ {
const size_t installed_remove_char_count = triplet.canonical_name().size() + 1; // +1 for the slash const size_t installed_remove_char_count = triplet.canonical_name().size() + 1; // +1 for the slash
std::vector<file_pack> installed_files = std::vector<file_pack> installed_files =
@ -198,13 +198,12 @@ namespace vcpkg::Install
const SortedVector<std::string> package_files = const SortedVector<std::string> package_files =
build_list_of_package_files(paths.get_filesystem(), package_dir); build_list_of_package_files(paths.get_filesystem(), package_dir);
const SortedVector<file_pack> installed_files = const SortedVector<file_pack> installed_files = build_list_of_installed_files(pgh_and_files, triplet);
build_list_of_installed_files(pgh_and_files, triplet);
struct intersection_compare struct intersection_compare
{ {
bool operator()(const std::string &lhs, const file_pack &rhs) { return lhs < rhs.first; } 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 file_pack& lhs, const std::string& rhs) { return lhs.first < rhs; }
}; };
std::vector<file_pack> intersection; std::vector<file_pack> intersection;
@ -216,11 +215,9 @@ namespace vcpkg::Install
std::back_inserter(intersection), std::back_inserter(intersection),
intersection_compare()); intersection_compare());
std::sort(intersection.begin(), intersection.end(), std::sort(intersection.begin(), intersection.end(), [](const file_pack& lhs, const file_pack& rhs) {
[](const file_pack &lhs, const file_pack &rhs) return lhs.second < rhs.second;
{ });
return lhs.second < rhs.second;
});
if (!intersection.empty()) if (!intersection.empty())
{ {
@ -231,19 +228,13 @@ namespace vcpkg::Install
bcf.core_paragraph.spec); bcf.core_paragraph.spec);
auto i = intersection.begin(); auto i = intersection.begin();
while (i != intersection.end()) { while (i != intersection.end())
{
System::print2("Installed by ", i->second, "\n "); System::print2("Installed by ", i->second, "\n ");
auto next = std::find_if(i, intersection.end(), auto next =
[i](const auto &val) std::find_if(i, intersection.end(), [i](const auto& val) { return i->second != val.second; });
{
return i->second != val.second;
});
System::print2(Strings::join("\n ", i, next, System::print2(Strings::join("\n ", i, next, [](const file_pack& file) { return file.first; }));
[](const file_pack &file)
{
return file.first;
}));
System::print2("\n\n"); System::print2("\n\n");
i = next; i = next;
@ -372,9 +363,8 @@ namespace vcpkg::Install
auto& fs = paths.get_filesystem(); auto& fs = paths.get_filesystem();
const fs::path download_dir = paths.downloads; const fs::path download_dir = paths.downloads;
std::error_code ec; std::error_code ec;
for(auto& p: fs.get_files_non_recursive(download_dir)) for (auto& p : fs.get_files_non_recursive(download_dir))
if (!fs.is_directory(p)) if (!fs.is_directory(p)) fs.remove(p);
fs.remove(p);
} }
return {code, std::move(bcf)}; return {code, std::move(bcf)};

View File

@ -19,8 +19,5 @@ namespace vcpkg
} }
} }
void to_string(std::string& out, PackageSpecParseResult p) void to_string(std::string& out, PackageSpecParseResult p) { out.append(vcpkg::to_string(p).c_str()); }
{
out.append(vcpkg::to_string(p).c_str());
}
} }

View File

@ -1,9 +1,9 @@
#include "pch.h" #include "pch.h"
#include <vcpkg/base/files.h> #include <vcpkg/base/files.h>
#include <vcpkg/base/system.debug.h>
#include <vcpkg/base/system.print.h> #include <vcpkg/base/system.print.h>
#include <vcpkg/base/util.h> #include <vcpkg/base/util.h>
#include <vcpkg/base/system.debug.h>
#include <vcpkg/paragraphparseresult.h> #include <vcpkg/paragraphparseresult.h>
#include <vcpkg/paragraphs.h> #include <vcpkg/paragraphs.h>

View File

@ -62,7 +62,7 @@ namespace vcpkg
#if defined(_WIN32) || defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) #if defined(_WIN32) || defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__)
static const std::string XML_VERSION = "2"; static const std::string XML_VERSION = "2";
static const fs::path XML_PATH = paths.scripts / "vcpkgTools.xml"; 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); static const std::string XML = paths.get_filesystem().read_contents(XML_PATH).value_or_exit(VCPKG_LINE_INFO);
std::smatch match_xml_version; std::smatch match_xml_version;
const bool has_xml_version = std::regex_search(XML.cbegin(), XML.cend(), match_xml_version, XML_VERSION_REGEX); 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, XML_VERSION,
match_xml_version[1]); 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; std::smatch match_tool_entry;
const bool has_tool_entry = std::regex_search(XML.cbegin(), XML.cend(), match_tool_entry, tool_regex); const bool has_tool_entry = std::regex_search(XML.cbegin(), XML.cend(), match_tool_entry, tool_regex);
if (!has_tool_entry) if (!has_tool_entry)
@ -109,13 +109,13 @@ namespace vcpkg
const fs::path tool_dir_path = paths.tools / tool_dir_name; const fs::path tool_dir_path = paths.tools / tool_dir_name;
const fs::path exe_path = tool_dir_path / exe_relative_path; const fs::path exe_path = tool_dir_path / exe_relative_path;
return ToolData {*version.get(), return ToolData{*version.get(),
exe_path, exe_path,
url, url,
paths.downloads / archive_name.value_or(exe_relative_path).to_string(), paths.downloads / archive_name.value_or(exe_relative_path).to_string(),
archive_name.has_value(), archive_name.has_value(),
tool_dir_path, tool_dir_path,
sha512}; sha512};
#endif #endif
} }
@ -156,7 +156,7 @@ namespace vcpkg
actual_version[2] >= expected_version[2]); actual_version[2] >= expected_version[2]);
if (!version_acceptable) continue; if (!version_acceptable) continue;
return PathAndVersion {candidate, *version}; return PathAndVersion{candidate, *version};
} }
return nullopt; return nullopt;

View File

@ -39,10 +39,7 @@ namespace vcpkg
#endif #endif
} }
static fs::path get_config_path() static fs::path get_config_path() { return get_user_dir() / "config"; }
{
return get_user_dir() / "config";
}
UserConfig UserConfig::try_read_data(const Files::Filesystem& fs) UserConfig UserConfig::try_read_data(const Files::Filesystem& fs)
{ {