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

This commit is contained in:
Robert Schumacher 2020-04-29 15:09:55 -07:00 committed by GitHub
parent 6ef805c2a9
commit 9b91a53606
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 8 deletions

View File

@ -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); 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]") TEST_CASE ("install default features of dependency test 3", "[plan]")
{ {
std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs; std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;

View File

@ -85,13 +85,14 @@ namespace vcpkg
Triplet triplet, Triplet triplet,
const std::string& abi_tag, const std::string& abi_tag,
const std::vector<FeatureSpec>& deps) const std::vector<FeatureSpec>& deps)
: version(spgh.version) : spec(spgh.name, triplet)
, version(spgh.version)
, description(spgh.description) , description(spgh.description)
, maintainer(spgh.maintainer) , maintainer(spgh.maintainer)
, abi(abi_tag) , abi(abi_tag)
, type(spgh.type) , 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(); }); this->depends = Util::fmap(deps, [](const FeatureSpec& spec) { return spec.spec().name(); });
Util::sort_unique_erase(this->depends); Util::sort_unique_erase(this->depends);
} }
@ -100,9 +101,14 @@ namespace vcpkg
const FeatureParagraph& fpgh, const FeatureParagraph& fpgh,
Triplet triplet, Triplet triplet,
const std ::vector<FeatureSpec>& deps) 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(); }); this->depends = Util::fmap(deps, [](const FeatureSpec& spec) { return spec.spec().name(); });
Util::sort_unique_erase(this->depends); 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'); 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'); 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');
} }
} }

View File

@ -106,15 +106,13 @@ namespace vcpkg::Dependencies
&m_scfl.source_control_file->find_dependencies_for_feature(feature).value_or_exit(VCPKG_LINE_INFO); &m_scfl.source_control_file->find_dependencies_for_feature(feature).value_or_exit(VCPKG_LINE_INFO);
std::vector<FeatureSpec> dep_list; std::vector<FeatureSpec> dep_list;
if (maybe_vars) if (auto vars = maybe_vars.get())
{ {
// Qualified dependency resolution is available // Qualified dependency resolution is available
auto fullspec_list = filter_dependencies( auto fullspec_list = filter_dependencies(*qualified_deps, m_spec.triplet(), *vars);
*qualified_deps, m_spec.triplet(), maybe_vars.value_or_exit(VCPKG_LINE_INFO));
for (auto&& fspec : fullspec_list) 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"})); Util::Vectors::append(&dep_list, fspec.to_feature_specs({"default"}, {"default"}));
} }