aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg_Dependencies.cpp
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-04-27 18:08:52 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2017-04-27 18:59:57 -0700
commit1e9471a1489156720362ef12e1ec6849ea9b45b6 (patch)
tree46f0f35093ecd18034c9f9463d6f8b7aa590ade0 /toolsrc/src/vcpkg_Dependencies.cpp
parent75e8752cb90eb8bc7717518d9d6a5c68f27f2b0f (diff)
downloadvcpkg-1e9471a1489156720362ef12e1ec6849ea9b45b6.tar.gz
vcpkg-1e9471a1489156720362ef12e1ec6849ea9b45b6.zip
Run clang-format over the cpp files
Diffstat (limited to 'toolsrc/src/vcpkg_Dependencies.cpp')
-rw-r--r--toolsrc/src/vcpkg_Dependencies.cpp160
1 files changed, 92 insertions, 68 deletions
diff --git a/toolsrc/src/vcpkg_Dependencies.cpp b/toolsrc/src/vcpkg_Dependencies.cpp
index 56bff7954..9a6428874 100644
--- a/toolsrc/src/vcpkg_Dependencies.cpp
+++ b/toolsrc/src/vcpkg_Dependencies.cpp
@@ -1,25 +1,24 @@
#include "pch.h"
-#include "vcpkg_Dependencies.h"
-#include "vcpkg_Graphs.h"
-#include "VcpkgPaths.h"
+
#include "PackageSpec.h"
+#include "Paragraphs.h"
#include "StatusParagraphs.h"
+#include "VcpkgPaths.h"
+#include "vcpkg_Dependencies.h"
#include "vcpkg_Files.h"
+#include "vcpkg_Graphs.h"
#include "vcpkg_Util.h"
#include "vcpkglib.h"
-#include "Paragraphs.h"
namespace vcpkg::Dependencies
{
std::vector<PackageSpec> AnyParagraph::dependencies(const Triplet& triplet) const
{
- auto to_package_specs = [&](const std::vector<std::string>& dependencies_as_string)
- {
- return Util::fmap(dependencies_as_string, [&](const std::string s)
- {
- return PackageSpec::from_name_and_triplet(s, triplet).value_or_exit(VCPKG_LINE_INFO);
- });
- };
+ auto to_package_specs = [&](const std::vector<std::string>& dependencies_as_string) {
+ return Util::fmap(dependencies_as_string, [&](const std::string s) {
+ return PackageSpec::from_name_and_triplet(s, triplet).value_or_exit(VCPKG_LINE_INFO);
+ });
+ };
if (auto p = this->status_paragraph.get())
{
@@ -36,28 +35,29 @@ namespace vcpkg::Dependencies
return to_package_specs(filter_dependencies(p->depends, triplet));
}
- Checks::exit_with_message(VCPKG_LINE_INFO, "Cannot get dependencies because there was none of: source/binary/status paragraphs");
+ Checks::exit_with_message(VCPKG_LINE_INFO,
+ "Cannot get dependencies because there was none of: source/binary/status paragraphs");
}
std::string to_output_string(RequestType request_type, const CStringView s)
{
switch (request_type)
{
- case RequestType::AUTO_SELECTED:
- return Strings::format(" * %s", s);
- case RequestType::USER_REQUESTED:
- return Strings::format(" %s", s);
- default:
- Checks::unreachable(VCPKG_LINE_INFO);
+ case RequestType::AUTO_SELECTED: return Strings::format(" * %s", s);
+ case RequestType::USER_REQUESTED: return Strings::format(" %s", s);
+ default: Checks::unreachable(VCPKG_LINE_INFO);
}
}
- InstallPlanAction::InstallPlanAction() : spec()
- , any_paragraph()
- , plan_type(InstallPlanType::UNKNOWN)
- , request_type(RequestType::UNKNOWN) { }
+ InstallPlanAction::InstallPlanAction()
+ : spec(), any_paragraph(), plan_type(InstallPlanType::UNKNOWN), request_type(RequestType::UNKNOWN)
+ {
+ }
- InstallPlanAction::InstallPlanAction(const PackageSpec& spec, const AnyParagraph& any_paragraph, const RequestType& request_type) : InstallPlanAction()
+ InstallPlanAction::InstallPlanAction(const PackageSpec& spec,
+ const AnyParagraph& any_paragraph,
+ const RequestType& request_type)
+ : InstallPlanAction()
{
this->spec = spec;
this->request_type = request_type;
@@ -90,25 +90,29 @@ namespace vcpkg::Dependencies
return left->spec.name() < right->spec.name();
}
- RemovePlanAction::RemovePlanAction() : plan_type(RemovePlanType::UNKNOWN)
- , request_type(RequestType::UNKNOWN) { }
+ RemovePlanAction::RemovePlanAction() : plan_type(RemovePlanType::UNKNOWN), request_type(RequestType::UNKNOWN) {}
- RemovePlanAction::RemovePlanAction(const PackageSpec& spec, const RemovePlanType& plan_type, const RequestType& request_type)
- : spec(spec)
- , plan_type(plan_type)
- , request_type(request_type) { }
+ RemovePlanAction::RemovePlanAction(const PackageSpec& spec,
+ const RemovePlanType& plan_type,
+ const RequestType& request_type)
+ : spec(spec), plan_type(plan_type), request_type(request_type)
+ {
+ }
bool ExportPlanAction::compare_by_name(const ExportPlanAction* left, const ExportPlanAction* right)
{
return left->spec.name() < right->spec.name();
}
- ExportPlanAction::ExportPlanAction() : spec()
- , any_paragraph()
- , plan_type(ExportPlanType::UNKNOWN)
- , request_type(RequestType::UNKNOWN) { }
+ ExportPlanAction::ExportPlanAction()
+ : spec(), any_paragraph(), plan_type(ExportPlanType::UNKNOWN), request_type(RequestType::UNKNOWN)
+ {
+ }
- ExportPlanAction::ExportPlanAction(const PackageSpec& spec, const AnyParagraph& any_paragraph, const RequestType& request_type) : ExportPlanAction()
+ ExportPlanAction::ExportPlanAction(const PackageSpec& spec,
+ const AnyParagraph& any_paragraph,
+ const RequestType& request_type)
+ : ExportPlanAction()
{
this->spec = spec;
this->request_type = request_type;
@@ -135,7 +139,9 @@ namespace vcpkg::Dependencies
return left->spec.name() < right->spec.name();
}
- std::vector<InstallPlanAction> create_install_plan(const VcpkgPaths& paths, const std::vector<PackageSpec>& specs, const StatusParagraphs& status_db)
+ std::vector<InstallPlanAction> create_install_plan(const VcpkgPaths& paths,
+ const std::vector<PackageSpec>& specs,
+ const StatusParagraphs& status_db)
{
struct InstallAdjacencyProvider final : Graphs::AdjacencyProvider<PackageSpec, InstallPlanAction>
{
@@ -143,20 +149,24 @@ namespace vcpkg::Dependencies
const StatusParagraphs& status_db;
const std::unordered_set<PackageSpec>& specs_as_set;
- InstallAdjacencyProvider(const VcpkgPaths& p, const StatusParagraphs& s, const std::unordered_set<PackageSpec>& specs_as_set) : paths(p)
- , status_db(s)
- , specs_as_set(specs_as_set) {}
+ InstallAdjacencyProvider(const VcpkgPaths& p,
+ const StatusParagraphs& s,
+ const std::unordered_set<PackageSpec>& specs_as_set)
+ : paths(p), status_db(s), specs_as_set(specs_as_set)
+ {
+ }
std::vector<PackageSpec> adjacency_list(const InstallPlanAction& plan) const override
{
- if (plan.any_paragraph.status_paragraph.get())
- return std::vector<PackageSpec>{};
+ if (plan.any_paragraph.status_paragraph.get()) return std::vector<PackageSpec>{};
return plan.any_paragraph.dependencies(plan.spec.triplet());
}
InstallPlanAction load_vertex_data(const PackageSpec& spec) const override
{
- const RequestType request_type = specs_as_set.find(spec) != specs_as_set.end() ? RequestType::USER_REQUESTED : RequestType::AUTO_SELECTED;
+ const RequestType request_type = specs_as_set.find(spec) != specs_as_set.end()
+ ? RequestType::USER_REQUESTED
+ : RequestType::AUTO_SELECTED;
auto it = status_db.find_installed(spec);
if (it != status_db.end())
return InstallPlanAction{ spec, { *it->get(), nullopt, nullopt }, request_type };
@@ -165,25 +175,28 @@ namespace vcpkg::Dependencies
if (auto bpgh = maybe_bpgh.get())
return InstallPlanAction{ spec, { nullopt, *bpgh, nullopt }, request_type };
- Expected<SourceParagraph> maybe_spgh = Paragraphs::try_load_port(paths.get_filesystem(), paths.port_dir(spec));
+ Expected<SourceParagraph> maybe_spgh =
+ Paragraphs::try_load_port(paths.get_filesystem(), paths.port_dir(spec));
if (auto spgh = maybe_spgh.get())
return InstallPlanAction{ spec, { nullopt, nullopt, *spgh }, request_type };
- return InstallPlanAction{ spec , { nullopt, nullopt, nullopt }, request_type };
+ return InstallPlanAction{ spec, { nullopt, nullopt, nullopt }, request_type };
}
};
const std::unordered_set<PackageSpec> specs_as_set(specs.cbegin(), specs.cend());
- std::vector<InstallPlanAction> toposort = Graphs::topological_sort(specs, InstallAdjacencyProvider{ paths, status_db, specs_as_set });
- Util::erase_remove_if(toposort, [](const InstallPlanAction& plan)
- {
- return plan.request_type == RequestType::AUTO_SELECTED && plan.plan_type == InstallPlanType::ALREADY_INSTALLED;
- });
+ std::vector<InstallPlanAction> toposort =
+ Graphs::topological_sort(specs, InstallAdjacencyProvider{ paths, status_db, specs_as_set });
+ Util::erase_remove_if(toposort, [](const InstallPlanAction& plan) {
+ return plan.request_type == RequestType::AUTO_SELECTED &&
+ plan.plan_type == InstallPlanType::ALREADY_INSTALLED;
+ });
return toposort;
}
- std::vector<RemovePlanAction> create_remove_plan(const std::vector<PackageSpec>& specs, const StatusParagraphs& status_db)
+ std::vector<RemovePlanAction> create_remove_plan(const std::vector<PackageSpec>& specs,
+ const StatusParagraphs& status_db)
{
struct RemoveAdjacencyProvider final : Graphs::AdjacencyProvider<PackageSpec, RemovePlanAction>
{
@@ -191,10 +204,12 @@ namespace vcpkg::Dependencies
const std::vector<StatusParagraph*>& installed_ports;
const std::unordered_set<PackageSpec>& specs_as_set;
- RemoveAdjacencyProvider(const StatusParagraphs& status_db, const std::vector<StatusParagraph*>& installed_ports, const std::unordered_set<PackageSpec>& specs_as_set)
- : status_db(status_db)
- , installed_ports(installed_ports)
- , specs_as_set(specs_as_set) { }
+ RemoveAdjacencyProvider(const StatusParagraphs& status_db,
+ const std::vector<StatusParagraph*>& installed_ports,
+ const std::unordered_set<PackageSpec>& specs_as_set)
+ : status_db(status_db), installed_ports(installed_ports), specs_as_set(specs_as_set)
+ {
+ }
std::vector<PackageSpec> adjacency_list(const RemovePlanAction& plan) const override
{
@@ -207,12 +222,10 @@ namespace vcpkg::Dependencies
std::vector<PackageSpec> dependents;
for (const StatusParagraph* an_installed_package : installed_ports)
{
- if (an_installed_package->package.spec.triplet() != spec.triplet())
- continue;
+ if (an_installed_package->package.spec.triplet() != spec.triplet()) continue;
const std::vector<std::string>& deps = an_installed_package->package.depends;
- if (std::find(deps.begin(), deps.end(), spec.name()) == deps.end())
- continue;
+ if (std::find(deps.begin(), deps.end(), spec.name()) == deps.end()) continue;
dependents.push_back(an_installed_package->package.spec);
}
@@ -222,7 +235,9 @@ namespace vcpkg::Dependencies
RemovePlanAction load_vertex_data(const PackageSpec& spec) const override
{
- const RequestType request_type = specs_as_set.find(spec) != specs_as_set.end() ? RequestType::USER_REQUESTED : RequestType::AUTO_SELECTED;
+ const RequestType request_type = specs_as_set.find(spec) != specs_as_set.end()
+ ? RequestType::USER_REQUESTED
+ : RequestType::AUTO_SELECTED;
const StatusParagraphs::const_iterator it = status_db.find_installed(spec);
if (it == status_db.end())
{
@@ -237,7 +252,9 @@ namespace vcpkg::Dependencies
return Graphs::topological_sort(specs, RemoveAdjacencyProvider{ status_db, installed_ports, specs_as_set });
}
- std::vector<ExportPlanAction> create_export_plan(const VcpkgPaths& paths, const std::vector<PackageSpec>& specs, const StatusParagraphs& status_db)
+ std::vector<ExportPlanAction> create_export_plan(const VcpkgPaths& paths,
+ const std::vector<PackageSpec>& specs,
+ const StatusParagraphs& status_db)
{
struct ExportAdjacencyProvider final : Graphs::AdjacencyProvider<PackageSpec, ExportPlanAction>
{
@@ -245,9 +262,12 @@ namespace vcpkg::Dependencies
const StatusParagraphs& status_db;
const std::unordered_set<PackageSpec>& specs_as_set;
- ExportAdjacencyProvider(const VcpkgPaths& p, const StatusParagraphs& s, const std::unordered_set<PackageSpec>& specs_as_set) : paths(p)
- , status_db(s)
- , specs_as_set(specs_as_set) {}
+ ExportAdjacencyProvider(const VcpkgPaths& p,
+ const StatusParagraphs& s,
+ const std::unordered_set<PackageSpec>& specs_as_set)
+ : paths(p), status_db(s), specs_as_set(specs_as_set)
+ {
+ }
std::vector<PackageSpec> adjacency_list(const ExportPlanAction& plan) const override
{
@@ -256,22 +276,26 @@ namespace vcpkg::Dependencies
ExportPlanAction load_vertex_data(const PackageSpec& spec) const override
{
- const RequestType request_type = specs_as_set.find(spec) != specs_as_set.end() ? RequestType::USER_REQUESTED : RequestType::AUTO_SELECTED;
+ const RequestType request_type = specs_as_set.find(spec) != specs_as_set.end()
+ ? RequestType::USER_REQUESTED
+ : RequestType::AUTO_SELECTED;
Expected<BinaryParagraph> maybe_bpgh = Paragraphs::try_load_cached_package(paths, spec);
if (auto bpgh = maybe_bpgh.get())
- return ExportPlanAction{ spec,{ nullopt, *bpgh, nullopt }, request_type };
+ return ExportPlanAction{ spec, { nullopt, *bpgh, nullopt }, request_type };
- Expected<SourceParagraph> maybe_spgh = Paragraphs::try_load_port(paths.get_filesystem(), paths.port_dir(spec));
+ Expected<SourceParagraph> maybe_spgh =
+ Paragraphs::try_load_port(paths.get_filesystem(), paths.port_dir(spec));
if (auto spgh = maybe_spgh.get())
- return ExportPlanAction{ spec,{ nullopt, nullopt, *spgh }, request_type };
+ return ExportPlanAction{ spec, { nullopt, nullopt, *spgh }, request_type };
- return ExportPlanAction{ spec ,{ nullopt, nullopt, nullopt }, request_type };
+ return ExportPlanAction{ spec, { nullopt, nullopt, nullopt }, request_type };
}
};
const std::unordered_set<PackageSpec> specs_as_set(specs.cbegin(), specs.cend());
- std::vector<ExportPlanAction> toposort = Graphs::topological_sort(specs, ExportAdjacencyProvider{ paths, status_db, specs_as_set });
+ std::vector<ExportPlanAction> toposort =
+ Graphs::topological_sort(specs, ExportAdjacencyProvider{ paths, status_db, specs_as_set });
return toposort;
}
}