Skip to content

Commit

Permalink
Engage default features if origin is not top level
Browse files Browse the repository at this point in the history
  • Loading branch information
dg0yt committed Feb 5, 2024
1 parent 5351595 commit c2a3e70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/vcpkg-test/dependencies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ static const PackageSpec& toplevel_spec()
return ret;
}

static PackageSpec toplevel_spec(const std::string& name) { return {name, Test::X86_WINDOWS}; }

struct MockOverlayProvider : IOverlayProvider
{
MockOverlayProvider() = default;
Expand Down Expand Up @@ -1618,7 +1620,7 @@ TEST_CASE ("version install default features", "[versionplan]")
bp.v["a"] = {"1", 0};

WITH_EXPECTED(install_plan,
create_versioned_install_plan(vp, bp, var_provider, {Dependency{"a"}}, {}, toplevel_spec()));
create_versioned_install_plan(vp, bp, var_provider, {Dependency{"a"}}, {}, toplevel_spec("a")));

REQUIRE(install_plan.size() == 1);
check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}, {"x"});
Expand All @@ -1638,8 +1640,9 @@ TEST_CASE ("version dont install default features", "[versionplan]")
MockBaselineProvider bp;
bp.v["a"] = {"1", 0};

auto install_plan = create_versioned_install_plan(vp, bp, var_provider, {CoreDependency{"a"}}, {}, toplevel_spec())
.value_or_exit(VCPKG_LINE_INFO);
auto install_plan =
create_versioned_install_plan(vp, bp, var_provider, {CoreDependency{"a"}}, {}, toplevel_spec("a"))
.value_or_exit(VCPKG_LINE_INFO);

REQUIRE(install_plan.size() == 1);
check_name_and_version(install_plan.install_actions[0], "a", {"1", 0});
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/dependencies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1649,9 +1649,9 @@ namespace vcpkg
}
}

// Implicit defaults are disabled if spec has been mentioned at top-level.
// Implicit defaults are disabled if spec is requested from top-level spec.
// Note that if top-level doesn't also mark that reference as `[core]`, defaults will be re-engaged.
it->second.default_features = !Util::Maps::contains(m_user_requested, spec);
it->second.default_features = origin != m_toplevel.name();
it->second.requested_features.insert("core");

require_scfl(*it, it->second.scfl, origin);
Expand Down

0 comments on commit c2a3e70

Please sign in to comment.