[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

@ -66,7 +66,8 @@ namespace vcpkg::Strings
}
template<class... Args>
[[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<class InputIterator, class Transformer>
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<class Container>

View File

@ -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
{

View File

@ -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;
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) {
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;

View File

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

View File

@ -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)

View File

@ -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>
@ -366,8 +366,7 @@ namespace vcpkg::Build
{"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())
@ -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
}

View File

@ -55,27 +55,20 @@ namespace vcpkg::Commands::CI
struct XunitTestResults
{
public:
XunitTestResults() { m_assembly_run_datetime = Chrono::CTime::get_current_date_time(); }
XunitTestResults()
{
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)
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
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,16 +115,18 @@ 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()
{
@ -150,10 +141,7 @@ namespace vcpkg::Commands::CI
collection.name,
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)
{
@ -165,19 +153,16 @@ namespace vcpkg::Commands::CI
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));
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::SUCCEEDED: result_string = "Pass"; break;
default: Checks::exit_fail(VCPKG_LINE_INFO); break;
}
std::string traits_block;
@ -203,7 +188,6 @@ namespace vcpkg::Commands::CI
std::string m_xml;
};
struct UnknownCIPortsResults
{
std::vector<FullPackageSpec> unknown;
@ -212,7 +196,8 @@ 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,
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,
@ -469,13 +454,19 @@ 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));

View File

@ -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,
{},

View File

@ -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 = {

View File

@ -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"});

View File

@ -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,
{},

View File

@ -162,8 +162,9 @@ namespace vcpkg::Install
}
}
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,8 +198,7 @@ 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
{
@ -216,9 +215,7 @@ namespace vcpkg::Install
std::back_inserter(intersection),
intersection_compare());
std::sort(intersection.begin(), intersection.end(),
[](const file_pack &lhs, const file_pack &rhs)
{
std::sort(intersection.begin(), intersection.end(), [](const file_pack& lhs, const file_pack& rhs) {
return lhs.second < rhs.second;
});
@ -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;
@ -373,8 +364,7 @@ namespace vcpkg::Install
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);
if (!fs.is_directory(p)) fs.remove(p);
}
return {code, std::move(bcf)};

View File

@ -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()); }
}

View File

@ -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>

View File

@ -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)
{