-
Notifications
You must be signed in to change notification settings - Fork 257
Expand file tree
/
Copy pathupdatevcpkg.ps1
More file actions
111 lines (83 loc) · 3.54 KB
/
Copy pathupdatevcpkg.ps1
File metadata and controls
111 lines (83 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<#
.NOTES
Copyright (c) Microsoft Corporation.
Licensed under the MIT License.
.SYNOPSIS
Updates the vcpkg port for DirectXMath to match a GitHub release.
.DESCRIPTION
This script updates the vcpkg port at D:\vcpkg\ports\directxmath to match a specific
GitHub release by tag. It updates the version-date in vcpkg.json and the tag and SHA512
hash in portfile.cmake for the source archive.
.PARAMETER Tag
The GitHub release tag (e.g., 'may2026', 'mar2026'). Defaults to the latest tag.
.LINK
https://github.com/microsoft/DirectXMath/wiki
#>
param(
[string]$Tag = ""
)
$repoRoot = Split-Path -Path $PSScriptRoot -Parent
$portDir = "D:\vcpkg\ports\directxmath"
$vcpkgJson = Join-Path $portDir "vcpkg.json"
$portfile = Join-Path $portDir "portfile.cmake"
if ((-Not (Test-Path $vcpkgJson)) -Or (-Not (Test-Path $portfile))) {
Write-Error "ERROR: Cannot find vcpkg port files at $portDir" -ErrorAction Stop
}
# Determine tag from latest git tag if not provided
if ($Tag.Length -eq 0) {
$Tag = (git --no-pager -C $repoRoot tag --sort=-creatordate | Select-Object -First 1).Trim()
if ($Tag.Length -eq 0) {
Write-Error "ERROR: Failed to determine latest tag!" -ErrorAction Stop
}
}
Write-Host "Release Tag: $Tag"
# Get version date from the git tag date
$tagDateStr = (git --no-pager -C $repoRoot log -1 --format=%ai $Tag).Trim()
if ([string]::IsNullOrEmpty($tagDateStr)) {
Write-Error "ERROR: Failed to get date for tag $Tag!" -ErrorAction Stop
}
$versionDate = ([datetime]::Parse($tagDateStr)).ToString("yyyy-MM-dd")
Write-Host "Version Date: $versionDate"
# --- Update vcpkg.json ---
Write-Host "`nUpdating vcpkg.json..."
$jsonContent = Get-Content $vcpkgJson -Raw
$jsonContent = $jsonContent -replace '"version-date":\s*"[^"]*"', "`"version-date`": `"$versionDate`""
$jsonContent = $jsonContent -replace ',\s*"port-version":\s*\d+', ''
$jsonContent = $jsonContent -replace '"port-version":\s*\d+,?\s*', ''
Set-Content -Path $vcpkgJson -Value $jsonContent -NoNewline
Write-Host " version-date set to $versionDate"
# --- Update portfile.cmake tag ---
Write-Host "`nUpdating portfile.cmake tag..."
$portContent = Get-Content $portfile -Raw
$portContent = $portContent -replace '(\n\s+REF\s+)\S+', "`${1}$Tag"
Set-Content -Path $portfile -Value $portContent -NoNewline
Write-Host " Tag set to $Tag"
# --- Download and hash source archive ---
$ProgressPreference = 'SilentlyContinue'
$tempDir = Join-Path $Env:Temp $(New-Guid)
New-Item -Type Directory -Path $tempDir | Out-Null
$sourceUrl = "https://github.com/Microsoft/DirectXMath/archive/refs/tags/$Tag.tar.gz"
$sourcePath = Join-Path $tempDir "$Tag.tar.gz"
Write-Host "`nDownloading source archive from $sourceUrl..."
try {
Invoke-WebRequest -Uri $sourceUrl -OutFile $sourcePath -ErrorAction Stop
}
catch {
Write-Error "ERROR: Failed to download source archive!" -ErrorAction Stop
}
$sourceHash = (Get-FileHash -Path $sourcePath -Algorithm SHA512).Hash.ToLower()
Write-Host " Source SHA512: $sourceHash"
# Replace SHA512 in vcpkg_from_github block
$portContent = Get-Content $portfile -Raw
$portContent = $portContent -replace '(vcpkg_from_github\s*\([^)]*SHA512\s+)[0-9a-fA-F]+', "`${1}$sourceHash"
Set-Content -Path $portfile -Value $portContent -NoNewline
# --- Cleanup ---
Remove-Item -Recurse -Force $tempDir
Write-Host "`nvcpkg port updated successfully!"
Write-Host "`nUpdated files:"
Write-Host " $vcpkgJson"
Write-Host " $portfile"
$portContent = Get-Content $portfile -Raw
if ($portContent -match '\bPATCHES\b') {
Write-Warning "This port includes patches. Review them to either remove or update."
}