|
1 | 1 | # Helper functions for dealing with the port overlay |
2 | 2 |
|
| 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 | + |
3 | 10 | $OverlayRoot = $PSScriptRoot |
4 | 11 |
|
5 | 12 | $ErrorActionPreference = "Stop" |
@@ -530,29 +537,59 @@ function Update-PortVersion |
530 | 537 | $portDefinition | ConvertTo-Json -Depth 5 | Out-File $portJsonPath |
531 | 538 | } |
532 | 539 |
|
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' |
535 | 565 |
|
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 |
539 | 569 |
|
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 |
543 | 573 |
|
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' |
550 | 580 |
|
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 |
557 | 587 |
|
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 | +} |
0 commit comments