diff --git a/toolsrc/include/vcpkg/dependencies.h b/toolsrc/include/vcpkg/dependencies.h index 4abeb678e6..de68d06e9b 100644 --- a/toolsrc/include/vcpkg/dependencies.h +++ b/toolsrc/include/vcpkg/dependencies.h @@ -162,10 +162,6 @@ namespace vcpkg::Dependencies std::unique_ptr m_graph; }; - std::vector create_install_plan(const PortFileProvider& port_file_provider, - const std::vector& specs, - const StatusParagraphs& status_db); - std::vector create_remove_plan(const std::vector& specs, const StatusParagraphs& status_db); diff --git a/toolsrc/src/tests.plan.cpp b/toolsrc/src/tests.plan.cpp index a4c628bf62..546e20b0dd 100644 --- a/toolsrc/src/tests.plan.cpp +++ b/toolsrc/src/tests.plan.cpp @@ -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) diff --git a/toolsrc/src/vcpkg/commands.ci.cpp b/toolsrc/src/vcpkg/commands.ci.cpp index 4636a57388..7672755ba4 100644 --- a/toolsrc/src/vcpkg/commands.ci.cpp +++ b/toolsrc/src/vcpkg/commands.ci.cpp @@ -20,27 +20,15 @@ namespace vcpkg::Commands::CI static Install::InstallSummary run_ci_on_triplet(const Triplet& triplet, const VcpkgPaths& paths, - const std::vector& ports, - const std::set& exclusions_set) + const std::vector& ports) { Input::check_triplet(triplet, paths); - - const std::vector specs = PackageSpec::to_package_specs(ports, triplet); + std::vector 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 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 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 ports = Install::get_all_port_names(paths); + std::vector ports = Install::get_all_port_names(paths); + Util::erase_remove_if(ports, [&](auto&& port) { return Util::Sets::contains(exclusions_set, port); }); + std::vector 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)}); } diff --git a/toolsrc/src/vcpkg/dependencies.cpp b/toolsrc/src/vcpkg/dependencies.cpp index fedda56ab3..793951ab5a 100644 --- a/toolsrc/src/vcpkg/dependencies.cpp +++ b/toolsrc/src/vcpkg/dependencies.cpp @@ -280,33 +280,6 @@ namespace vcpkg::Dependencies return nullopt; } - std::vector create_install_plan(const PortFileProvider& port_file_provider, - const std::vector& 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 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 create_remove_plan(const std::vector& specs, const StatusParagraphs& status_db) {