[vcpkg] Remove create_install_plan in favor of create_feature_install_plan

This commit is contained in:
Robert Schumacher 2018-02-19 07:11:30 -08:00
parent d6ff55a735
commit 12f19c7a30
4 changed files with 35 additions and 72 deletions

View File

@ -162,10 +162,6 @@ namespace vcpkg::Dependencies
std::unique_ptr<ClusterGraph> m_graph;
};
std::vector<InstallPlanAction> create_install_plan(const PortFileProvider& port_file_provider,
const std::vector<PackageSpec>& specs,
const StatusParagraphs& status_db);
std::vector<RemovePlanAction> create_remove_plan(const std::vector<PackageSpec>& specs,
const StatusParagraphs& status_db);

View File

@ -111,13 +111,13 @@ namespace UnitTest1
auto spec_c = spec_map.emplace("c");
Dependencies::MapPortFileProvider map_port(spec_map.map);
auto install_plan =
Dependencies::create_install_plan(map_port, {spec_a}, StatusParagraphs(std::move(status_paragraphs)));
auto install_plan = Dependencies::create_feature_install_plan(
map_port, {FeatureSpec{spec_a, ""}}, StatusParagraphs(std::move(status_paragraphs)));
Assert::AreEqual(size_t(3), install_plan.size());
Assert::AreEqual("c", install_plan[0].spec.name().c_str());
Assert::AreEqual("b", install_plan[1].spec.name().c_str());
Assert::AreEqual("a", install_plan[2].spec.name().c_str());
Assert::AreEqual("c", install_plan[0].spec().name().c_str());
Assert::AreEqual("b", install_plan[1].spec().name().c_str());
Assert::AreEqual("a", install_plan[2].spec().name().c_str());
}
TEST_METHOD(multiple_install_scheme)
@ -135,12 +135,14 @@ namespace UnitTest1
auto spec_h = spec_map.emplace("h");
Dependencies::MapPortFileProvider map_port(spec_map.map);
auto install_plan = Dependencies::create_install_plan(
map_port, {spec_a, spec_b, spec_c}, StatusParagraphs(std::move(status_paragraphs)));
auto install_plan = Dependencies::create_feature_install_plan(
map_port,
{FeatureSpec{spec_a, ""}, FeatureSpec{spec_b, ""}, FeatureSpec{spec_c, ""}},
StatusParagraphs(std::move(status_paragraphs)));
auto iterator_pos = [&](const PackageSpec& spec) -> int {
auto it = std::find_if(
install_plan.begin(), install_plan.end(), [&](auto& action) { return action.spec == spec; });
install_plan.begin(), install_plan.end(), [&](auto& action) { return action.spec() == spec; });
Assert::IsTrue(it != install_plan.end());
return (int)(it - install_plan.begin());
};
@ -228,18 +230,18 @@ namespace UnitTest1
auto spec_k = spec_map.emplace("k");
Dependencies::MapPortFileProvider map_port(spec_map.map);
auto install_plan =
Dependencies::create_install_plan(map_port, {spec_a}, StatusParagraphs(std::move(status_paragraphs)));
auto install_plan = Dependencies::create_feature_install_plan(
map_port, {FeatureSpec{spec_a, ""}}, StatusParagraphs(std::move(status_paragraphs)));
Assert::AreEqual(size_t(8), install_plan.size());
Assert::AreEqual("h", install_plan[0].spec.name().c_str());
Assert::AreEqual("g", install_plan[1].spec.name().c_str());
Assert::AreEqual("f", install_plan[2].spec.name().c_str());
Assert::AreEqual("e", install_plan[3].spec.name().c_str());
Assert::AreEqual("d", install_plan[4].spec.name().c_str());
Assert::AreEqual("c", install_plan[5].spec.name().c_str());
Assert::AreEqual("b", install_plan[6].spec.name().c_str());
Assert::AreEqual("a", install_plan[7].spec.name().c_str());
Assert::AreEqual("h", install_plan[0].spec().name().c_str());
Assert::AreEqual("g", install_plan[1].spec().name().c_str());
Assert::AreEqual("f", install_plan[2].spec().name().c_str());
Assert::AreEqual("e", install_plan[3].spec().name().c_str());
Assert::AreEqual("d", install_plan[4].spec().name().c_str());
Assert::AreEqual("c", install_plan[5].spec().name().c_str());
Assert::AreEqual("b", install_plan[6].spec().name().c_str());
Assert::AreEqual("a", install_plan[7].spec().name().c_str());
}
TEST_METHOD(basic_feature_test_1)

View File

@ -20,27 +20,15 @@ namespace vcpkg::Commands::CI
static Install::InstallSummary run_ci_on_triplet(const Triplet& triplet,
const VcpkgPaths& paths,
const std::vector<std::string>& ports,
const std::set<std::string>& exclusions_set)
const std::vector<std::string>& ports)
{
Input::check_triplet(triplet, paths);
const std::vector<PackageSpec> specs = PackageSpec::to_package_specs(ports, triplet);
std::vector<PackageSpec> specs = PackageSpec::to_package_specs(ports, triplet);
auto featurespecs = Util::fmap(specs, [](auto& spec) { return FeatureSpec(spec, ""); });
StatusParagraphs status_db = database_load_check(paths);
const auto& paths_port_file = Dependencies::PathsPortFileProvider(paths);
std::vector<InstallPlanAction> install_plan =
Dependencies::create_install_plan(paths_port_file, specs, status_db);
for (InstallPlanAction& plan : install_plan)
{
if (Util::Sets::contains(exclusions_set, plan.spec.name()))
{
plan.plan_type = InstallPlanType::EXCLUDED;
}
}
Checks::check_exit(VCPKG_LINE_INFO, !install_plan.empty(), "Install plan cannot be empty");
auto action_plan = Dependencies::create_feature_install_plan(paths_port_file, featurespecs, status_db);
const Build::BuildPackageOptions install_plan_options = {
Build::UseHeadVersion::NO,
@ -48,11 +36,13 @@ namespace vcpkg::Commands::CI
Build::CleanBuildtrees::YES,
};
const std::vector<Dependencies::AnyAction> action_plan =
Util::fmap(install_plan, [&install_plan_options](InstallPlanAction& install_action) {
install_action.build_options = install_plan_options;
return Dependencies::AnyAction(std::move(install_action));
});
for (auto&& action : action_plan)
{
if (auto p = action.install_action.get())
{
p->build_options = install_plan_options;
}
}
return Install::perform(action_plan, Install::KeepGoing::YES, paths, status_db);
}
@ -102,11 +92,13 @@ namespace vcpkg::Commands::CI
triplets.push_back(default_triplet);
}
const std::vector<std::string> ports = Install::get_all_port_names(paths);
std::vector<std::string> ports = Install::get_all_port_names(paths);
Util::erase_remove_if(ports, [&](auto&& port) { return Util::Sets::contains(exclusions_set, port); });
std::vector<TripletAndSummary> results;
for (const Triplet& triplet : triplets)
{
Install::InstallSummary summary = run_ci_on_triplet(triplet, paths, ports, exclusions_set);
Install::InstallSummary summary = run_ci_on_triplet(triplet, paths, ports);
results.push_back({triplet, std::move(summary)});
}

View File

@ -280,33 +280,6 @@ namespace vcpkg::Dependencies
return nullopt;
}
std::vector<InstallPlanAction> create_install_plan(const PortFileProvider& port_file_provider,
const std::vector<PackageSpec>& specs,
const StatusParagraphs& status_db)
{
auto fspecs = Util::fmap(specs, [](const PackageSpec& spec) { return FeatureSpec(spec, ""); });
auto plan = create_feature_install_plan(port_file_provider, fspecs, status_db);
std::vector<InstallPlanAction> ret;
ret.reserve(plan.size());
for (auto&& action : plan)
{
if (auto p_install = action.install_action.get())
{
ret.push_back(std::move(*p_install));
}
else
{
Checks::exit_with_message(VCPKG_LINE_INFO,
"The installation plan requires feature packages support. Please re-run the "
"command with --featurepackages.");
}
}
return ret;
}
std::vector<RemovePlanAction> create_remove_plan(const std::vector<PackageSpec>& specs,
const StatusParagraphs& status_db)
{