aboutsummaryrefslogtreecommitdiff
path: root/toolsrc
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2016-11-15 11:56:46 -0800
committerAlexander Karatarakis <alkarata@microsoft.com>2016-11-15 12:40:06 -0800
commit2b204e673914b20e662ed17f667c267690fd6b52 (patch)
tree7eefa5c0855be954ef5efd401aad4ef44e47c198 /toolsrc
parent2584f3e3def7f09bc373117985013ac019aa76d6 (diff)
downloadvcpkg-2b204e673914b20e662ed17f667c267690fd6b52.tar.gz
vcpkg-2b204e673914b20e662ed17f667c267690fd6b52.zip
Use custom struct instead of std::pair
Diffstat (limited to 'toolsrc')
-rw-r--r--toolsrc/include/vcpkg_Dependencies.h8
-rw-r--r--toolsrc/src/commands_installation.cpp34
-rw-r--r--toolsrc/src/vcpkg_Dependencies.cpp10
3 files changed, 29 insertions, 23 deletions
diff --git a/toolsrc/include/vcpkg_Dependencies.h b/toolsrc/include/vcpkg_Dependencies.h
index b556eb7d8..909c27771 100644
--- a/toolsrc/include/vcpkg_Dependencies.h
+++ b/toolsrc/include/vcpkg_Dependencies.h
@@ -20,5 +20,11 @@ namespace vcpkg {namespace Dependencies
std::unique_ptr<SourceParagraph> spgh;
};
- std::vector<std::pair<package_spec, install_plan_action>> create_install_plan(const vcpkg_paths& paths, const std::vector<package_spec>& specs, const StatusParagraphs& status_db);
+ struct package_spec_with_install_plan
+ {
+ package_spec spec;
+ install_plan_action install_plan;
+ };
+
+ std::vector<package_spec_with_install_plan> create_install_plan(const vcpkg_paths& paths, const std::vector<package_spec>& specs, const StatusParagraphs& status_db);
}}
diff --git a/toolsrc/src/commands_installation.cpp b/toolsrc/src/commands_installation.cpp
index b900b56c8..4535484b6 100644
--- a/toolsrc/src/commands_installation.cpp
+++ b/toolsrc/src/commands_installation.cpp
@@ -73,11 +73,11 @@ namespace vcpkg
auto install_plan = Dependencies::create_install_plan(paths, specs, status_db);
Checks::check_exit(!install_plan.empty(), "Install plan cannot be empty");
- std::string specs_string = to_string(install_plan[0].first);
+ std::string specs_string = to_string(install_plan[0].spec);
for (size_t i = 1; i < install_plan.size(); ++i)
{
specs_string.push_back(',');
- specs_string.append(to_string(install_plan[i].first));
+ specs_string.append(to_string(install_plan[i].spec));
}
TrackProperty("installplan", specs_string);
Environment::ensure_utilities_on_path(paths);
@@ -86,31 +86,31 @@ namespace vcpkg
{
try
{
- if (action.second.plan == Dependencies::install_plan_kind::ALREADY_INSTALLED)
+ if (action.install_plan.plan == Dependencies::install_plan_kind::ALREADY_INSTALLED)
{
- if (std::find(specs.begin(), specs.end(), action.first) != specs.end())
+ if (std::find(specs.begin(), specs.end(), action.spec) != specs.end())
{
- System::println(System::color::success, "Package %s is already installed", action.first);
+ System::println(System::color::success, "Package %s is already installed", action.spec);
}
}
- else if (action.second.plan == Dependencies::install_plan_kind::BUILD_AND_INSTALL)
+ else if (action.install_plan.plan == Dependencies::install_plan_kind::BUILD_AND_INSTALL)
{
- build_internal(*action.second.spgh, action.first, paths, paths.port_dir(action.first));
- auto bpgh = try_load_cached_package(paths, action.first).get_or_throw();
+ build_internal(*action.install_plan.spgh, action.spec, paths, paths.port_dir(action.spec));
+ auto bpgh = try_load_cached_package(paths, action.spec).get_or_throw();
install_package(paths, bpgh, status_db);
- System::println(System::color::success, "Package %s is installed", action.first);
+ System::println(System::color::success, "Package %s is installed", action.spec);
}
- else if (action.second.plan == Dependencies::install_plan_kind::INSTALL)
+ else if (action.install_plan.plan == Dependencies::install_plan_kind::INSTALL)
{
- install_package(paths, *action.second.bpgh, status_db);
- System::println(System::color::success, "Package %s is installed", action.first);
+ install_package(paths, *action.install_plan.bpgh, status_db);
+ System::println(System::color::success, "Package %s is installed", action.spec);
}
else
Checks::unreachable();
}
catch (const std::exception& e)
{
- System::println(System::color::error, "Error: Could not install package %s: %s", action.first, e.what());
+ System::println(System::color::error, "Error: Could not install package %s: %s", action.spec, e.what());
exit(EXIT_FAILURE);
}
}
@@ -144,11 +144,11 @@ namespace vcpkg
first_level_deps_specs.push_back(package_spec::from_name_and_triplet(dep, spec.target_triplet()).get_or_throw());
}
- auto unmet_dependencies = Dependencies::create_install_plan(paths, first_level_deps_specs, status_db);
+ std::vector<Dependencies::package_spec_with_install_plan> unmet_dependencies = Dependencies::create_install_plan(paths, first_level_deps_specs, status_db);
unmet_dependencies.erase(
- std::remove_if(unmet_dependencies.begin(), unmet_dependencies.end(), [](auto& p)
+ std::remove_if(unmet_dependencies.begin(), unmet_dependencies.end(), [](const Dependencies::package_spec_with_install_plan& p)
{
- return p.second.plan == Dependencies::install_plan_kind::ALREADY_INSTALLED;
+ return p.install_plan.plan == Dependencies::install_plan_kind::ALREADY_INSTALLED;
}),
unmet_dependencies.end());
@@ -159,7 +159,7 @@ namespace vcpkg
System::println("");
for (const auto& p : unmet_dependencies)
{
- System::println(" %s", to_string(p.first));
+ System::println(" %s", to_string(p.spec));
}
System::println("");
exit(EXIT_FAILURE);
diff --git a/toolsrc/src/vcpkg_Dependencies.cpp b/toolsrc/src/vcpkg_Dependencies.cpp
index 3142b44ba..2b7e132cc 100644
--- a/toolsrc/src/vcpkg_Dependencies.cpp
+++ b/toolsrc/src/vcpkg_Dependencies.cpp
@@ -11,7 +11,7 @@
namespace vcpkg { namespace Dependencies
{
- std::vector<std::pair<package_spec, install_plan_action>> create_install_plan(const vcpkg_paths& paths, const std::vector<package_spec>& specs, const StatusParagraphs& status_db)
+ std::vector<package_spec_with_install_plan> create_install_plan(const vcpkg_paths& paths, const std::vector<package_spec>& specs, const StatusParagraphs& status_db)
{
std::unordered_map<package_spec, install_plan_action> was_examined; // Examine = we have checked its immediate (non-recursive) dependencies
Graphs::Graph<package_spec> graph;
@@ -63,12 +63,12 @@ namespace vcpkg { namespace Dependencies
was_examined.emplace(spec, install_plan_action{install_plan_kind::BUILD_AND_INSTALL, nullptr, std::make_unique<SourceParagraph>(std::move(*spgh))});
}
- std::vector<std::pair<package_spec, install_plan_action>> ret;
+ std::vector<package_spec_with_install_plan> ret;
- std::vector<package_spec> pkgs = graph.find_topological_sort();
- for (package_spec& pkg : pkgs)
+ const std::vector<package_spec> pkgs = graph.find_topological_sort();
+ for (const package_spec& pkg : pkgs)
{
- ret.emplace_back(pkg, std::move(was_examined[pkg]));
+ ret.push_back({ pkg, std::move(was_examined[pkg]) });
}
return ret;
}