Skip to content

Commit b6e1da0

Browse files
committed
Removed checked-in ports in favor of script at build time
1 parent 4dd878c commit b6e1da0

3 files changed

Lines changed: 62 additions & 59 deletions

File tree

azure-pipelines.yml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -720,28 +720,3 @@ jobs:
720720
env:
721721
onefuzzDropDirectory: '$(buildOutDir)\WinGetYamlFuzzing'
722722
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
723-
724-
- job: 'VerifyPortOverlay'
725-
displayName: 'Verify Port Overlay'
726-
variables:
727-
runCodesignValidationInjection: ${{ false }}
728-
skipComponentGovernanceDetection: ${{ true }}
729-
730-
steps:
731-
- task: PowerShell@2
732-
displayName: Regenerate Port Overlay
733-
inputs:
734-
filePath: 'src\VcpkgPortOverlay\CreatePortOverlay.ps1'
735-
workingDirectory: 'src\VcpkgPortOverlay'
736-
737-
- task: PowerShell@2
738-
displayName: Verify No Changes
739-
inputs:
740-
targetType: inline
741-
script: |
742-
$diff = git diff --name-only src/VcpkgPortOverlay
743-
if ($diff) {
744-
Write-Host "##[error]Port overlay is out of sync. Run CreatePortOverlay.ps1 and commit the result."
745-
Write-Host $diff
746-
exit 1
747-
}

src/VcpkgPortOverlay/CreatePortOverlay.ps1

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Helper functions for dealing with the port overlay
22

3+
[CmdletBinding()]
4+
param(
5+
# When provided, serializes concurrent invocations via a named mutex and skips work
6+
# if the stamp file is already up-to-date. Used by VcpkgPortOverlay.proj.
7+
[string]$StampFile
8+
)
9+
310
$OverlayRoot = $PSScriptRoot
411

512
$ErrorActionPreference = "Stop"
@@ -530,29 +537,59 @@ function Update-PortVersion
530537
$portDefinition | ConvertTo-Json -Depth 5 | Out-File $portJsonPath
531538
}
532539

533-
New-PortOverlay cpprestsdk -Version 2.10.18 -PortVersion 4
534-
Add-LocalPatch cpprestsdk 'add-server-certificate-validation.patch'
540+
# Acquire mutex if running from MSBuild (StampFile provided) to serialize parallel project builds
541+
$_mutex = $null
542+
if ($StampFile) {
543+
$_mutex = [System.Threading.Mutex]::new($false, 'Local\WingetVcpkgPortOverlay')
544+
try { $_mutex.WaitOne() | Out-Null } catch [System.Threading.AbandonedMutexException] {}
545+
546+
# Another process may have already rebuilt the overlay while we waited; skip if so.
547+
if (Test-Path $StampFile) {
548+
$stampTime = (Get-Item $StampFile).LastWriteTime
549+
550+
$overlayInputs = @($PSCommandPath)
551+
if (Test-Path $OverlayRoot\patches) {
552+
$overlayInputs += Get-ChildItem -Path $OverlayRoot\patches -Recurse -File
553+
}
554+
555+
if (-not ($overlayInputs | Where-Object { $_.LastWriteTime -gt $stampTime } | Select-Object -First 1)) {
556+
$_mutex.ReleaseMutex()
557+
return
558+
}
559+
}
560+
}
561+
562+
try {
563+
New-PortOverlay cpprestsdk -Version 2.10.18 -PortVersion 4
564+
Add-LocalPatch cpprestsdk 'add-server-certificate-validation.patch'
535565

536-
New-PortOverlay detours -Version 4.0.1 -PortVersion 8
537-
Update-PortSource detours -RefPattern 'v4.0.1' -Commit '404c153ff390cb14f1787c7feeb4908c6d79b0ab' -SourceHash '1f3f26657927fa153116dce13dbfa3319ea368e6c9017f4999b6ec24d6356c335b3d5326718d3ec707b92832763ffea092088df52596f016d7ca9b8127f7033d'
538-
Remove-PortPatches detours
566+
New-PortOverlay detours -Version 4.0.1 -PortVersion 8
567+
Update-PortSource detours -RefPattern 'v4.0.1' -Commit '404c153ff390cb14f1787c7feeb4908c6d79b0ab' -SourceHash '1f3f26657927fa153116dce13dbfa3319ea368e6c9017f4999b6ec24d6356c335b3d5326718d3ec707b92832763ffea092088df52596f016d7ca9b8127f7033d'
568+
Remove-PortPatches detours
539569

540-
New-PortOverlay libyaml -Version 0.2.5 -PortVersion 5
541-
Update-PortSource libyaml -Commit '840b65c40675e2d06bf40405ad3f12dec7f35923' -SourceHash 'de85560312d53a007a2ddf1fe403676bbd34620480b1ba446b8c16bb366524ba7a6ed08f6316dd783bf980d9e26603a9efc82f134eb0235917b3be1d3eb4b302'
542-
Update-PortVersion libyaml
570+
New-PortOverlay libyaml -Version 0.2.5 -PortVersion 5
571+
Update-PortSource libyaml -Commit '840b65c40675e2d06bf40405ad3f12dec7f35923' -SourceHash 'de85560312d53a007a2ddf1fe403676bbd34620480b1ba446b8c16bb366524ba7a6ed08f6316dd783bf980d9e26603a9efc82f134eb0235917b3be1d3eb4b302'
572+
Update-PortVersion libyaml
543573

544-
# sfs-client is not in the official vcpkg registry.
545-
# The port is based on the template from the sfs-client repository.
546-
# See: https://github.com/microsoft/sfs-client/tree/main/sfs-client-vcpkg-port/sfs-client
547-
$SfsClientCommit = '0e27525d597c730e71646fd0b15bdc8c8503f24d'
548-
$SfsClientSha512 = 'd926d7fdbbd120cbcbd9732a3300cccfeed4a90d6b94456d73a70675df3578a91127f7e9f310fe68d18fa34bb997c29c8455e586d81a2ba404cf19193a80ca6e'
549-
$SfsClientVersion = '1.1.0'
574+
# sfs-client is not in the official vcpkg registry.
575+
# The port is based on the template from the sfs-client repository.
576+
# See: https://github.com/microsoft/sfs-client/tree/main/sfs-client-vcpkg-port/sfs-client
577+
$SfsClientCommit = '0e27525d597c730e71646fd0b15bdc8c8503f24d'
578+
$SfsClientSha512 = 'd926d7fdbbd120cbcbd9732a3300cccfeed4a90d6b94456d73a70675df3578a91127f7e9f310fe68d18fa34bb997c29c8455e586d81a2ba404cf19193a80ca6e'
579+
$SfsClientVersion = '1.1.0'
550580

551-
New-PortOverlayFromGitHub 'sfs-client' -Repo 'microsoft/sfs-client' -Commit $SfsClientCommit -SubPath 'sfs-client-vcpkg-port/sfs-client'
552-
Expand-PortfileTemplate 'sfs-client'
553-
Set-PortFilePlaceholder 'sfs-client' 'portfile.cmake' -Placeholder 'commit-id' -Value $SfsClientCommit
554-
Set-ParameterInPortFile 'sfs-client' -ParameterName 'SHA512' -CurrentValuePattern '0' -NewValue $SfsClientSha512
555-
Set-CmakeConfigureOptions 'sfs-client' -Options @('-DSFS_BUILD_TESTS=OFF', '-DSFS_BUILD_SAMPLES=OFF')
556-
Set-PortFilePlaceholder 'sfs-client' 'vcpkg.json' -Placeholder 'VERSION' -Value $SfsClientVersion
581+
New-PortOverlayFromGitHub 'sfs-client' -Repo 'microsoft/sfs-client' -Commit $SfsClientCommit -SubPath 'sfs-client-vcpkg-port/sfs-client'
582+
Expand-PortfileTemplate 'sfs-client'
583+
Set-PortFilePlaceholder 'sfs-client' 'portfile.cmake' -Placeholder 'commit-id' -Value $SfsClientCommit
584+
Set-ParameterInPortFile 'sfs-client' -ParameterName 'SHA512' -CurrentValuePattern '0' -NewValue $SfsClientSha512
585+
Set-CmakeConfigureOptions 'sfs-client' -Options @('-DSFS_BUILD_TESTS=OFF', '-DSFS_BUILD_SAMPLES=OFF')
586+
Set-PortFilePlaceholder 'sfs-client' 'vcpkg.json' -Placeholder 'VERSION' -Value $SfsClientVersion
557587

558-
Add-LocalPatch 'sfs-client' 'remove-unconditional-toolchain-override.patch'
588+
Add-LocalPatch 'sfs-client' 'remove-unconditional-toolchain-override.patch'
589+
590+
if ($StampFile) {
591+
$null = New-Item -ItemType File -Path $StampFile -Force
592+
}
593+
} finally {
594+
if ($_mutex) { $_mutex.ReleaseMutex() }
595+
}

src/vcpkg.props

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,11 @@
5252
<WriteLinesToFile File="$(_TripletFile)" Lines="$(VcpkgTriplet)" Overwrite="true" />
5353
</Target>
5454

55-
<!-- Recreate the port overlay when the script or local patches change.
56-
Uses MSBuild incremental build (Inputs/Outputs) so the script only runs
57-
when the stamp file is missing or an input is newer than the stamp. -->
58-
<ItemGroup>
59-
<_VcpkgPortOverlayInput Include="$(MSBuildThisFileDirectory)VcpkgPortOverlay\CreatePortOverlay.ps1" />
60-
<_VcpkgPortOverlayInput Include="$(MSBuildThisFileDirectory)VcpkgPortOverlay\patches\**\*" />
61-
</ItemGroup>
62-
55+
<!-- Build the port overlay before any project that needs it. Incremental logic and
56+
parallel-build serialization live in CreatePortOverlay.ps1 itself. -->
6357
<Target Name="CreateVcpkgPortOverlay"
64-
BeforeTargets="PrepareForBuild"
65-
Inputs="@(_VcpkgPortOverlayInput)"
66-
Outputs="$(MSBuildThisFileDirectory)VcpkgPortOverlay\.created">
67-
<Exec Command="powershell.exe -ExecutionPolicy Bypass -File &quot;$(MSBuildThisFileDirectory)VcpkgPortOverlay\CreatePortOverlay.ps1&quot;" />
68-
<Touch Files="$(MSBuildThisFileDirectory)VcpkgPortOverlay\.created" AlwaysCreate="true" />
58+
BeforeTargets="VcpkgInstallManifestDependencies">
59+
<Exec Command="pwsh.exe -ExecutionPolicy Bypass -File &quot;$(MSBuildThisFileDirectory)VcpkgPortOverlay\CreatePortOverlay.ps1&quot; -StampFile &quot;$(MSBuildThisFileDirectory)VcpkgPortOverlay\.created&quot;" />
6960
</Target>
7061

7162
<Target Name="EnsureNoTripletMismatch"

0 commit comments

Comments
 (0)