[vcpkg] Correctly record default feature list in BinaryParagraphs. Fixes
MODIFY
src/vcpkg-test/plan.cpp
src/vcpkg-test/plan.cpp
@@ -624,6 +624,34 @@ TEST_CASE ("do not install default features of existing dependency", "[plan]")
features_check(install_plan.install_actions.at(0), "a", {"core"}, Triplet::X64_WINDOWS);
}
+TEST_CASE ("install default features of existing dependency", "[plan]")
+{
+ // Add a port "a" which depends on the default features of "b"
+ PackageSpecMap spec_map(Triplet::X64_WINDOWS);
+ spec_map.emplace("a", "b");
+ // "b" has a default feature
+ spec_map.emplace("b", "", {{"b1", ""}}, {"b1"});
+
+ std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
+ // "b[core]" is already installed
+ status_paragraphs.push_back(make_status_pgh("b", "", "b1"));
+ status_paragraphs.back()->package.spec = PackageSpec("b", Triplet::X64_WINDOWS);
+
+ // Install "a" (without explicit feature specification)
+ auto install_specs = FullPackageSpec::from_string("a", Triplet::X64_WINDOWS);
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
+ auto install_plan = Dependencies::create_feature_install_plan(map_port,
+ var_provider,
+ {install_specs.value_or_exit(VCPKG_LINE_INFO)},
+ StatusParagraphs(std::move(status_paragraphs)));
+
+ // Expect "b" to be rebuilt
+ REQUIRE(install_plan.install_actions.size() == 2);
+ features_check(install_plan.install_actions.at(0), "b", {"core", "b1"}, Triplet::X64_WINDOWS);
+}
+
TEST_CASE ("install default features of dependency test 3", "[plan]")
{
std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;

MODIFY
src/vcpkg/binaryparagraph.cpp
src/vcpkg/binaryparagraph.cpp
@@ -85,13 +85,14 @@ namespace vcpkg
Triplet triplet,
const std::string& abi_tag,
const std::vector<FeatureSpec>& deps)
- : version(spgh.version)
+ : spec(spgh.name, triplet)
+ , version(spgh.version)
, description(spgh.description)
, maintainer(spgh.maintainer)
, abi(abi_tag)
, type(spgh.type)
+ , default_features(spgh.default_features)
{
- this->spec = PackageSpec(spgh.name, triplet);
this->depends = Util::fmap(deps, [](const FeatureSpec& spec) { return spec.spec().name(); });
Util::sort_unique_erase(this->depends);
}
@@ -100,9 +101,14 @@ namespace vcpkg
const FeatureParagraph& fpgh,
Triplet triplet,
const std ::vector<FeatureSpec>& deps)
- : version(), description(fpgh.description), maintainer(), feature(fpgh.name), type(spgh.type)
+ : spec(spgh.name, triplet)
+ , version()
+ , description(fpgh.description)
+ , maintainer()
+ , feature(fpgh.name)
+ , type(spgh.type)
+ , default_features()
{
- this->spec = PackageSpec(spgh.name, triplet);
this->depends = Util::fmap(deps, [](const FeatureSpec& spec) { return spec.spec().name(); });
Util::sort_unique_erase(this->depends);
}
@@ -143,5 +149,7 @@ namespace vcpkg
if (!pgh.description.empty()) out_str.append("Description: ").append(pgh.description).push_back('\n');
out_str.append("Type: ").append(Type::to_string(pgh.type)).push_back('\n');
+ if (!pgh.default_features.empty())
+ out_str.append("Default-Features: ").append(Strings::join(", ", pgh.default_features)).push_back('\n');
}
}

MODIFY
src/vcpkg/dependencies.cpp
src/vcpkg/dependencies.cpp
@@ -106,15 +106,13 @@ namespace vcpkg::Dependencies
&m_scfl.source_control_file->find_dependencies_for_feature(feature).value_or_exit(VCPKG_LINE_INFO);
std::vector<FeatureSpec> dep_list;
- if (maybe_vars)
+ if (auto vars = maybe_vars.get())
{
// Qualified dependency resolution is available
- auto fullspec_list = filter_dependencies(
- *qualified_deps, m_spec.triplet(), maybe_vars.value_or_exit(VCPKG_LINE_INFO));
+ auto fullspec_list = filter_dependencies(*qualified_deps, m_spec.triplet(), *vars);
for (auto&& fspec : fullspec_list)
{
- // TODO: this is incorrect and does not handle default features nor "*"
Util::Vectors::append(&dep_list, fspec.to_feature_specs({"default"}, {"default"}));
}

[vcpkg] Correctly record default feature list in BinaryParagraphs. Fixes #10678. (#11085)