diff --git a/azure-pipelines/e2e_ci/zzz-expected-port/portfile.cmake b/azure-pipelines/e2e_ci/zzz-expected-port/portfile.cmake new file mode 100644 index 0000000000..065116c276 --- /dev/null +++ b/azure-pipelines/e2e_ci/zzz-expected-port/portfile.cmake @@ -0,0 +1 @@ +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/azure-pipelines/e2e_ci/zzz-expected-port/vcpkg.json b/azure-pipelines/e2e_ci/zzz-expected-port/vcpkg.json new file mode 100644 index 0000000000..01923be8d1 --- /dev/null +++ b/azure-pipelines/e2e_ci/zzz-expected-port/vcpkg.json @@ -0,0 +1,10 @@ +{ + "name": "zzz-expected-port", + "version": "1", + "features": { + "zzz-unexpected-feature": { + "description": "Cannot be installed", + "supports": "native & !native" + } + } +} diff --git a/azure-pipelines/e2e_ci/zzz-unexpected-port/portfile.cmake b/azure-pipelines/e2e_ci/zzz-unexpected-port/portfile.cmake new file mode 100644 index 0000000000..065116c276 --- /dev/null +++ b/azure-pipelines/e2e_ci/zzz-unexpected-port/portfile.cmake @@ -0,0 +1 @@ +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/azure-pipelines/e2e_ci/zzz-unexpected-port/vcpkg.json b/azure-pipelines/e2e_ci/zzz-unexpected-port/vcpkg.json new file mode 100644 index 0000000000..cd8a19b49e --- /dev/null +++ b/azure-pipelines/e2e_ci/zzz-unexpected-port/vcpkg.json @@ -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" + ] + } + ] +} diff --git a/azure-pipelines/end-to-end-tests-dir/ci.ps1 b/azure-pipelines/end-to-end-tests-dir/ci.ps1 index 660fbb868f..ad3341911b 100644 --- a/azure-pipelines/end-to-end-tests-dir/ci.ps1 +++ b/azure-pipelines/end-to-end-tests-dir/ci.ps1 @@ -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"' +} diff --git a/src/vcpkg/commands.ci.cpp b/src/vcpkg/commands.ci.cpp index 998c30711c..3be9ab9046 100644 --- a/src/vcpkg/commands.ci.cpp +++ b/src/vcpkg/commands.ci.cpp @@ -149,6 +149,7 @@ namespace vcpkg::Commands::CI const std::vector& specs, const CreateInstallPlanOptions& serialize_options) { + // Initialize for all ports std::vector packages_with_qualified_deps; for (auto&& spec : specs) { @@ -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());