[vcpkg] Support self-referencing manifest files
MODIFY
azure-pipelines/end-to-end-tests-dir/manifests.ps1
azure-pipelines/end-to-end-tests-dir/manifests.ps1
@@ -79,3 +79,34 @@ Throw-IfFailed
Write-Trace "test manifest features: no-default-features, features = [no-default-features-2]"
Run-Vcpkg install @noDefaultFeatureArgs --x-feature=no-default-features-2
Throw-IfFailed
+
+$vcpkgJson = @{
+ 'name' = "manifest-test";
+ 'version' = "1.0.0";
+ 'features' = @{
+ 'a' = feature 'manifest-test';
+ }
+}
+
+Set-Content -Path "$manifestDir/vcpkg.json" `
+ -Value (ConvertTo-Json -Depth 5 -InputObject $vcpkgJson) `
+ -Encoding Ascii -NoNewline
+
+$vcpkgJson = @{
+ 'name' = "manifest-test";
+ 'version' = "1.0.0";
+ 'dependencies' = @( "nonexistent-port" )
+}
+
+New-Item -Path $manifestDir/manifest-test -ItemType Directory
+Set-Content -Path "$manifestDir/manifest-test/vcpkg.json" `
+ -Value (ConvertTo-Json -Depth 5 -InputObject $vcpkgJson) `
+ -Encoding Ascii -NoNewline
+
+Write-Trace "test manifest features: self-reference, features = [a]"
+Run-Vcpkg install @manifestDirArgs --x-feature=a
+Throw-IfFailed
+
+Write-Trace "test manifest features: self-reference, features = [a], with overlay"
+Run-Vcpkg install @manifestDirArgs --x-feature=a "--overlay-ports=$manifestDir/manifest-test"
+Throw-IfFailed

MODIFY
src/vcpkg/install.cpp
src/vcpkg/install.cpp
@@ -802,7 +802,6 @@ namespace vcpkg::Install
prohibit_backcompat_features ? Build::BackcompatFeatures::PROHIBIT : Build::BackcompatFeatures::ALLOW,
};
- PortFileProvider::PathsPortFileProvider provider(paths, args.overlay_ports);
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
auto& var_provider = *var_provider_storage;
@@ -897,16 +896,22 @@ namespace vcpkg::Install
}
auto verprovider = PortFileProvider::make_versioned_portfile_provider(paths);
auto baseprovider = PortFileProvider::make_baseline_provider(paths);
- auto oprovider = PortFileProvider::make_overlay_provider(paths, args.overlay_ports);
- auto install_plan =
- Dependencies::create_versioned_install_plan(*verprovider,
+ std::vector<std::string> extended_overlay_ports;
+ extended_overlay_ports.reserve(args.overlay_ports.size() + 1);
+ extended_overlay_ports.push_back(fs::u8string(manifest_path.parent_path()));
+ Util::Vectors::append(&extended_overlay_ports, args.overlay_ports);
+ System::print2(Strings::join(",", extended_overlay_ports), "\n");
+ auto oprovider = PortFileProvider::make_overlay_provider(paths, extended_overlay_ports);
+
+ PackageSpec toplevel{manifest_scf.core_paragraph->name, default_triplet};
+ auto install_plan = Dependencies::create_versioned_install_plan(*verprovider,
*baseprovider,
*oprovider,
var_provider,
dependencies,
manifest_scf.core_paragraph->overrides,
- {manifest_scf.core_paragraph->name, default_triplet},
+ toplevel,
host_triplet)
.value_or_exit(VCPKG_LINE_INFO);
@@ -917,6 +922,12 @@ namespace vcpkg::Install
action.build_options.editable = Build::Editable::NO;
}
+ // If the manifest refers to itself, it will be added to the install plan.
+ Util::erase_remove_if(install_plan.install_actions,
+ [&toplevel](auto&& action) { return action.spec == toplevel; });
+
+ PortFileProvider::PathsPortFileProvider provider(paths, extended_overlay_ports);
+
Commands::SetInstalled::perform_and_exit_ex(args,
paths,
provider,
@@ -927,6 +938,8 @@ namespace vcpkg::Install
pkgsconfig);
}
+ PortFileProvider::PathsPortFileProvider provider(paths, args.overlay_ports);
+
const std::vector<FullPackageSpec> specs = Util::fmap(args.command_arguments, [&](auto&& arg) {
return Input::check_and_get_full_package_spec(
std::string(arg), default_triplet, COMMAND_STRUCTURE.example_text);

[vcpkg] Support self-referencing manifest files (#15)