Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't let unsupported ports pull in dependencies #846

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions azure-pipelines/e2e_ci/zzz-expected-port/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
10 changes: 10 additions & 0 deletions azure-pipelines/e2e_ci/zzz-expected-port/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "zzz-expected-port",
"version": "1",
"features": {
"zzz-unexpected-feature": {
"description": "Cannot be installed",
"supports": "native & !native"
}
}
}
1 change: 1 addition & 0 deletions azure-pipelines/e2e_ci/zzz-unexpected-port/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
14 changes: 14 additions & 0 deletions azure-pipelines/e2e_ci/zzz-unexpected-port/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "zzz-unexpected-port",
"version": "1",
"description": "Cannot be installed",
"supports": "native & !native",
"dependencies": [
{
"name": "zzz-expected-port",
"features": [
"zzz-unexpected-feature"
]
}
]
}
19 changes: 16 additions & 3 deletions azure-pipelines/end-to-end-tests-dir/ci.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
. $PSScriptRoot/../end-to-end-tests-prelude.ps1

# Not a number
Run-Vcpkg ci --triplet=$Triplet --x-skipped-cascade-count=fish
Run-Vcpkg ci --dry-run --triplet=$Triplet --x-skipped-cascade-count=fish
Throw-IfNotFailed

# Negative
Run-Vcpkg ci --triplet=$Triplet --x-skipped-cascade-count=-1
Run-Vcpkg ci --dry-run --triplet=$Triplet --x-skipped-cascade-count=-1
Throw-IfNotFailed

# Clearly not the correct answer
Run-Vcpkg ci --triplet=$Triplet --x-skipped-cascade-count=1000
Run-Vcpkg ci --dry-run --triplet=$Triplet --x-skipped-cascade-count=1000
Throw-IfNotFailed

# Regular ci; may take a few seconds to complete
$port_list = Run-VcpkgAndCaptureOutput ci --dry-run --triplet=$Triplet --binarysource=clear --overlay-ports="$PSScriptRoot/../e2e_ci"
Throw-IfFailed
if ($port_list -match "zzz-unexpected-port[^ ]*[ ]*->") {
throw 'Detected installation of "zzz-unexpected-port"'
}
if ($port_list -match "zzz-unexpected-feature[^ ]*[ ]*->") {
throw 'Detected installation of "zzz-unexpected-feature"'
}
if ($port_list -notmatch "zzz-expected-port[^ ]*[ ]*->") {
throw 'Did not detect installation of "zzz-expected-port"'
}
16 changes: 14 additions & 2 deletions src/vcpkg/commands.ci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ namespace vcpkg::Commands::CI
const std::vector<FullPackageSpec>& specs,
const CreateInstallPlanOptions& serialize_options)
{
// Initialize for all ports
std::vector<PackageSpec> packages_with_qualified_deps;
for (auto&& spec : specs)
{
Expand All @@ -158,10 +159,21 @@ namespace vcpkg::Commands::CI
packages_with_qualified_deps.push_back(spec.package_spec);
}
}

var_provider.load_dep_info_vars(packages_with_qualified_deps, serialize_options.host_triplet);
auto action_plan = create_feature_install_plan(provider, var_provider, specs, {}, serialize_options);
var_provider.load_tag_vars(specs, provider, serialize_options.host_triplet);

// Determine set of ports which is applicable to the target
const auto applicable_specs = Util::filter(specs, [&](auto& spec) -> bool {
auto&& scfl = provider.get_control_file(spec.package_spec.name()).value_or_exit(VCPKG_LINE_INFO);
const auto& supports_expression = scfl.source_control_file->core_paragraph->supports_expression;
return supports_expression.is_empty()
? true
: supports_expression.evaluate(
var_provider.get_tag_vars(spec.package_spec).value_or_exit(VCPKG_LINE_INFO));
});

// Create install plan and complement initialization for ports to be installed for the host
auto action_plan = create_feature_install_plan(provider, var_provider, applicable_specs, {}, serialize_options);
var_provider.load_tag_vars(action_plan, provider, serialize_options.host_triplet);

Checks::check_exit(VCPKG_LINE_INFO, action_plan.already_installed.empty());
Expand Down