Skip to content

Commit 874e302

Browse files
authored
Fix overlay-ports behavior for manifest customers. (#1586)
In #1534 I introduced a bug which causes the builtin ports directory to "win" over declared command line --overlay-ports. This was not discovered in testing because the overlay-ports tests don't actually test with names that are also in the builtin ports directory.
1 parent 1a23f1a commit 874e302

File tree

8 files changed

+33
-6
lines changed

8 files changed

+33
-6
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This port is intentionally malformed and should not be loaded, because ../../a should be loaded instead
2+
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "a",
3+
"version": "0",
4+
"intentionally-malformed"
5+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "a",
3+
"version": "0"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$comment": "'config-overlays/a' in . should get loaded first, so we should never consider 'builtin-malformed/a'",
3+
"overlay-ports": [ "config-overlays" ]
4+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": [
3+
"a"
4+
]
5+
}

azure-pipelines/end-to-end-tests-dir/overlays.ps1

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ $manifestInfoPath = Join-Path -Path $vcpkgDir -ChildPath "manifest-info.json"
66
# Tests a simple project with overlay ports and triplets configured on a vcpkg-configuration.json file
77
Copy-Item -Recurse -LiteralPath @(
88
"$PSScriptRoot/../e2e-projects/overlays-malformed-shadowing",
9+
"$PSScriptRoot/../e2e-projects/overlays-malformed-shadowing-builtin",
910
"$PSScriptRoot/../e2e-projects/overlays-project-config-embedded",
1011
"$PSScriptRoot/../e2e-projects/overlays-project-with-config"
1112
) $TestingRoot
@@ -40,9 +41,9 @@ try {
4041
--overlay-triplets=$manifestRoot/my-triplets `
4142
--x-install-root=$installRoot `
4243
--triplet fancy-config-embedded-triplet
43-
Throw-IfFailed
44+
Throw-IfFailed
4445
} finally {
45-
popd
46+
popd
4647
}
4748

4849
# Config with bad paths
@@ -59,6 +60,11 @@ $manifestRoot = "$TestingRoot/overlays-malformed-shadowing"
5960
Run-Vcpkg install --x-manifest-root=$manifestRoot
6061
Throw-IfFailed
6162

63+
# ... even if that subsequent port is the builtin root
64+
$manifestRoot = "$TestingRoot/overlays-malformed-shadowing-builtin"
65+
Run-Vcpkg install --x-manifest-root=$manifestRoot --x-builtin-ports-root "$manifestRoot/builtin-malformed"
66+
Throw-IfFailed
67+
6268
# Test overlay_triplet paths remain relative to the manifest root after x-update-baseline
6369
$manifestRoot = "$TestingRoot/overlays-project-with-config"
6470
$configurationBefore = Get-Content "$manifestRoot/vcpkg-configuration.json" | ConvertFrom-Json

src/vcpkg/portfileprovider.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,14 @@ namespace vcpkg
257257

258258
OverlayPortIndex(const OverlayPortPaths& paths)
259259
{
260-
if (auto builtin_overlay_port_dir = paths.builtin_overlay_port_dir.get())
260+
for (auto&& overlay_port : paths.overlay_ports)
261261
{
262-
m_entries.emplace_back(OverlayPortKind::Directory, *builtin_overlay_port_dir);
262+
m_entries.emplace_back(OverlayPortKind::Unknown, overlay_port);
263263
}
264264

265-
for (auto&& overlay_port : paths.overlay_ports)
265+
if (auto builtin_overlay_port_dir = paths.builtin_overlay_port_dir.get())
266266
{
267-
m_entries.emplace_back(OverlayPortKind::Unknown, overlay_port);
267+
m_entries.emplace_back(OverlayPortKind::Directory, *builtin_overlay_port_dir);
268268
}
269269
}
270270

0 commit comments

Comments
 (0)