Skip to content

Commit

Permalink
[vcpkg] Correctly record default feature list in BinaryParagraphs. Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0219-msft committed Apr 29, 2020
1 parent ce8b01a commit d3456ba
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
28 changes: 28 additions & 0 deletions toolsrc/src/vcpkg-test/plan.cpp
Expand Up @@ -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;
Expand Down
14 changes: 10 additions & 4 deletions toolsrc/src/vcpkg/binaryparagraph.cpp
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
6 changes: 2 additions & 4 deletions toolsrc/src/vcpkg/dependencies.cpp
Expand Up @@ -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"}));
}

Expand Down

0 comments on commit d3456ba

Please sign in to comment.