diff --git a/include/vcpkg-test/mockcmakevarprovider.h b/include/vcpkg-test/mockcmakevarprovider.h index 1393a5843d..3dd263de97 100644 --- a/include/vcpkg-test/mockcmakevarprovider.h +++ b/include/vcpkg-test/mockcmakevarprovider.h @@ -19,10 +19,12 @@ namespace vcpkg::Test dep_info_vars.emplace(spec, SMap{}); } - void load_tag_vars(const ActionPlan& action_plan, Triplet host_triplet) const override + void load_tag_vars(Span specs, + Span /*port_locations*/, + Triplet host_triplet) const override { - for (auto&& install_action : action_plan.install_actions) - tag_vars.emplace(install_action.spec, SMap{}); + for (auto&& spec : specs) + tag_vars.emplace(spec.package_spec, SMap{}); (void)(host_triplet); } diff --git a/include/vcpkg/cmakevars.h b/include/vcpkg/cmakevars.h index 097cd99f3c..970216b017 100644 --- a/include/vcpkg/cmakevars.h +++ b/include/vcpkg/cmakevars.h @@ -1,5 +1,7 @@ #pragma once +#include + #include #include #include @@ -32,7 +34,11 @@ namespace vcpkg::CMakeVars virtual void load_dep_info_vars(Span specs, Triplet host_triplet) const = 0; - virtual void load_tag_vars(const ActionPlan& action_plan, Triplet host_triplet) const = 0; + virtual void load_tag_vars(Span specs, + Span port_locations, + Triplet host_triplet) const = 0; + + void load_tag_vars(const ActionPlan& action_plan, Triplet host_triplet) const; }; std::unique_ptr make_triplet_cmake_var_provider(const VcpkgPaths& paths); diff --git a/src/vcpkg/cmakevars.cpp b/src/vcpkg/cmakevars.cpp index d1fa63c448..6c8859cbc0 100644 --- a/src/vcpkg/cmakevars.cpp +++ b/src/vcpkg/cmakevars.cpp @@ -15,6 +15,23 @@ using namespace vcpkg; namespace vcpkg::CMakeVars { + + void CMakeVarProvider::load_tag_vars(const ActionPlan& action_plan, Triplet host_triplet) const + { + std::vector install_package_specs; + std::vector port_locations; + install_package_specs.reserve(action_plan.install_actions.size()); + port_locations.reserve(action_plan.install_actions.size()); + for (auto&& action : action_plan.install_actions) + { + install_package_specs.emplace_back(action.spec, action.feature_list); + port_locations.emplace_back( + action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO).source_location); + } + + load_tag_vars(install_package_specs, port_locations, host_triplet); + } + const std::unordered_map& CMakeVarProvider::get_or_load_dep_info_vars( const PackageSpec& spec, Triplet host_triplet) const { @@ -39,7 +56,9 @@ namespace vcpkg::CMakeVars void load_dep_info_vars(View specs, Triplet host_triplet) const override; - void load_tag_vars(const ActionPlan& action_plan, Triplet host_triplet) const override; + void load_tag_vars(Span specs, + Span port_locations, + Triplet host_triplet) const override; Optional&> get_generic_triplet_vars( Triplet triplet) const override; @@ -358,18 +377,19 @@ endfunction() } } - void TripletCMakeVarProvider::load_tag_vars(const ActionPlan& action_plan, Triplet host_triplet) const + void TripletCMakeVarProvider::load_tag_vars(Span specs, + Span port_locations, + Triplet host_triplet) const { - if (action_plan.install_actions.empty()) return; + if (specs.empty()) return; std::vector> spec_abi_settings; - spec_abi_settings.reserve(action_plan.install_actions.size()); + spec_abi_settings.reserve(specs.size()); + Checks::check_exit(VCPKG_LINE_INFO, specs.size() == port_locations.size()); - for (const auto& install_action : action_plan.install_actions) + for (size_t i = 0; i < specs.size(); ++i) { - auto& scfl = install_action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO); - const auto override_path = scfl.source_location / "vcpkg-abi-settings.cmake"; - spec_abi_settings.emplace_back(FullPackageSpec{install_action.spec, install_action.feature_list}, - override_path.generic_u8string()); + const auto override_path = port_locations[i] / "vcpkg-abi-settings.cmake"; + spec_abi_settings.emplace_back(specs[i], override_path.generic_u8string()); } std::vector>> vars(spec_abi_settings.size()); diff --git a/src/vcpkg/commands.test-features.cpp b/src/vcpkg/commands.test-features.cpp index d3ab77b486..282d54a049 100644 --- a/src/vcpkg/commands.test-features.cpp +++ b/src/vcpkg/commands.test-features.cpp @@ -283,6 +283,7 @@ namespace vcpkg::Commands::TestFeatures msg::println(msgComputeInstallPlans, msg::count = specs_to_test.size()); std::vector specs; + std::vector port_locations; std::vector actions_to_check; CreateInstallPlanOptions install_plan_options{host_triplet, paths.packages(), UnsupportedPortAction::Warn}; auto install_plans = Util::fmap(specs_to_test, [&](auto& spec) { @@ -293,13 +294,15 @@ namespace vcpkg::Commands::TestFeatures for (auto& actions : install_plan.install_actions) { specs.emplace_back(actions.spec, actions.feature_list); + port_locations.emplace_back( + actions.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO).source_location); } actions_to_check.push_back(&install_plan.install_actions.back()); } return std::make_pair(spec, std::move(install_plan)); }); msg::println(msgComputeAllAbis); - var_provider.load_tag_vars(specs, provider, host_triplet); + var_provider.load_tag_vars(specs, port_locations, host_triplet); StatusParagraphs status_db = database_load_check(paths.get_filesystem(), paths.installed()); PortAbiCache cache; for (auto& [spec, install_plan] : install_plans)