Skip to content

Commit 07d8a68

Browse files
authored
Added some helper scripts (#601)
1 parent f17ad4f commit 07d8a68

4 files changed

Lines changed: 300 additions & 18 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ packages
3131
/out
3232
/CMakeUserPresets.json
3333
/build/vcpkg_installed
34+
/build/*.exe

CMakePresets.json

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
"version": 3,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 21
6+
},
37
"configurePresets": [
48
{
59
"name": "base",
@@ -10,14 +14,15 @@
1014
"binaryDir": "${sourceDir}/out/build/${presetName}",
1115
"installDir": "${sourceDir}/out/install/${presetName}"
1216
},
13-
1417
{
1518
"name": "x64",
1619
"architecture": {
1720
"value": "x64",
1821
"strategy": "external"
1922
},
20-
"cacheVariables": { "DIRECTX_ARCH": "x64" },
23+
"cacheVariables": {
24+
"DIRECTX_ARCH": "x64"
25+
},
2126
"hidden": true
2227
},
2328
{
@@ -26,7 +31,9 @@
2631
"value": "x86",
2732
"strategy": "external"
2833
},
29-
"cacheVariables": { "DIRECTX_ARCH": "x86" },
34+
"cacheVariables": {
35+
"DIRECTX_ARCH": "x86"
36+
},
3037
"hidden": true
3138
},
3239
{
@@ -35,7 +42,9 @@
3542
"value": "arm64",
3643
"strategy": "external"
3744
},
38-
"cacheVariables": { "DIRECTX_ARCH": "arm64" },
45+
"cacheVariables": {
46+
"DIRECTX_ARCH": "arm64"
47+
},
3948
"hidden": true
4049
},
4150
{
@@ -44,29 +53,30 @@
4453
"value": "arm64ec",
4554
"strategy": "external"
4655
},
47-
"cacheVariables": { "DIRECTX_ARCH": "arm64ec" },
56+
"cacheVariables": {
57+
"DIRECTX_ARCH": "arm64ec"
58+
},
4859
"environment": {
4960
"CFLAGS": "/arm64EC",
5061
"CXXFLAGS": "/arm64EC"
5162
},
5263
"hidden": true
5364
},
54-
5565
{
5666
"name": "Debug",
57-
"cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" },
67+
"cacheVariables": {
68+
"CMAKE_BUILD_TYPE": "Debug"
69+
},
5870
"hidden": true
5971
},
6072
{
6173
"name": "Release",
62-
"cacheVariables":
63-
{
64-
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
65-
"CMAKE_INTERPROCEDURAL_OPTIMIZATION": true
74+
"cacheVariables": {
75+
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
76+
"CMAKE_INTERPROCEDURAL_OPTIMIZATION": true
6677
},
6778
"hidden": true
6879
},
69-
7080
{
7181
"name": "MSVC",
7282
"hidden": true,
@@ -116,7 +126,6 @@
116126
"strategy": "external"
117127
}
118128
},
119-
120129
{
121130
"name": "XAudio2Redist",
122131
"cacheVariables": {
@@ -211,19 +220,16 @@
211220
"strategy": "external"
212221
}
213222
},
214-
215223
{
216224
"name": "Analyze",
217-
"cacheVariables":
218-
{
225+
"cacheVariables": {
219226
"ENABLE_CODE_ANALYSIS": true
220227
},
221228
"hidden": true
222229
},
223230
{
224231
"name": "Coverage",
225-
"cacheVariables":
226-
{
232+
"cacheVariables": {
227233
"BUILD_TOOLS": false,
228234
"ENABLE_CODE_COVERAGE": true
229235
},
@@ -338,6 +344,7 @@
338344
{ "name": "x64-Coverage-Clang", "description": "Clang/LLVM for x64 (Debug) w/ Code Coverage", "inherits": [ "base", "x64", "Debug", "Clang", "Coverage" ] },
339345
{ "name": "x64-Fuzzing" , "description": "MSVC for x64 (Release) with ASan", "inherits": [ "base", "x64", "Release", "MSVC", "Win10", "Fuzzing" ] }
340346
],
347+
341348
"testPresets": [
342349
{ "name": "x64-Debug" , "configurePreset": "x64-Debug" },
343350
{ "name": "x64-Release" , "configurePreset": "x64-Release" },

build/downloadbuild.ps1

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
<#
2+
3+
.NOTES
4+
Copyright (c) Microsoft Corporation.
5+
Licensed under the MIT License.
6+
7+
.SYNOPSIS
8+
Downloads build artifacts from Azure DevOps for DirectXTK.
9+
10+
.DESCRIPTION
11+
This script is used as part of the internal release process for DirectXTK.
12+
13+
.PARAMETER BuildId
14+
This is the specific build to get artifacts from.
15+
16+
.PARAMETER PAT
17+
Requires an ADO PAT with 'Build > Read' scope. Can be provided via the ADO_PERSONAL_ACCESS_TOKEN environment variable or as a parameter.
18+
19+
.LINK
20+
https://github.com/microsoft/DirectXTK/wiki
21+
22+
#>
23+
24+
param(
25+
[Parameter(Mandatory)]
26+
[int]$BuildId,
27+
[string]$PAT = ""
28+
)
29+
30+
# Parse PAT
31+
if ($PAT.Length -eq 0) {
32+
$PAT = $env:ADO_PERSONAL_ACCESS_TOKEN
33+
34+
if ($PAT.Length -eq 0) {
35+
Write-Error "##[error]This script requires a valid ADO Personal Access Token!" -ErrorAction Stop
36+
}
37+
}
38+
39+
# Initial REST query
40+
$headers = @{
41+
"Content-Type" = "application/json"
42+
Authorization = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$PAT"))
43+
}
44+
45+
$uriFormat = "https://dev.azure.com/MSCodeHub/ab27a052-7f0e-4cba-9bec-d298c5942ab9/_apis/build/builds/{0}/artifacts?artifactName={1}&api-version=7.1"
46+
47+
$uriarm64 = $uriFormat -f $BuildId, "DirectXTK_Binaries_Release_ARM64"
48+
$uriamd64 = $uriFormat -f $BuildId, "DirectXTK_Binaries_Release_x64"
49+
50+
try
51+
{
52+
Write-Host "Checking if build and artifacts exist..."
53+
$responseamd64 = Invoke-RestMethod -Uri $uriamd64 -Method Get -Headers $headers
54+
$responsearm64 = Invoke-RestMethod -Uri $uriarm64 -Method Get -Headers $headers
55+
}
56+
catch
57+
{
58+
Write-Error "##[error]Build $BuildId not found!" -ErrorAction Continue
59+
}
60+
61+
$ProgressPreference = 'SilentlyContinue'
62+
63+
$tempFolderPath = Join-Path $Env:Temp $(New-Guid)
64+
New-Item -Type Directory -Path $tempFolderPath | Out-Null
65+
66+
Write-Host $tempFolderPath
67+
68+
$headers = @{
69+
Authorization = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$PAT"))
70+
Accept = "application/zip"
71+
}
72+
73+
Add-Type -A System.IO.Compression.FileSystem
74+
75+
# Download artifacts for ARM64
76+
foreach ($artifact in $responsearm64) {
77+
$artifactName = $artifact.name
78+
$downloadUrl = $artifact.resource.downloadUrl
79+
$outputFile = Join-Path $tempFolderPath "$artifactName.zip"
80+
81+
try
82+
{
83+
Write-Host "Downloading $artifactName to $outputFile..."
84+
Invoke-WebRequest -Uri $downloadUrl -Headers $headers -OutFile $outputFile
85+
}
86+
catch
87+
{
88+
Write-Error "##[error]Failed to download $artifactName!" -ErrorAction Continue
89+
}
90+
91+
try
92+
{
93+
Write-Host "Extracting $artifactName..."
94+
[IO.Compression.ZipFile]::ExtractToDirectory($outputFile, $tempFolderPath)
95+
}
96+
catch
97+
{
98+
Write-Error "##[error]Failed to extract $artifactName!" -ErrorAction Continue
99+
}
100+
}
101+
102+
# Download artifacts for X64
103+
foreach ($artifact in $responseamd64) {
104+
$artifactName = $artifact.name
105+
$downloadUrl = $artifact.resource.downloadUrl
106+
$outputFile = Join-Path $tempFolderPath "$artifactName.zip"
107+
108+
try
109+
{
110+
Write-Host "Downloading $artifactName to $outputFile..."
111+
Invoke-WebRequest -Uri $downloadUrl -Headers $headers -OutFile $outputFile
112+
}
113+
catch
114+
{
115+
Write-Error "##[error]Failed to download $artifactName!" -ErrorAction Continue
116+
}
117+
118+
try
119+
{
120+
Write-Host "Extracting $artifactName..."
121+
[IO.Compression.ZipFile]::ExtractToDirectory($outputFile, $tempFolderPath)
122+
}
123+
catch
124+
{
125+
Write-Error "##[error]Failed to extract $artifactName!" -ErrorAction Continue
126+
}
127+
}
128+
129+
# Extract command-line tool binary
130+
$exe = "XWBTool"
131+
132+
$binPath = Join-Path $tempFolderPath "DirectXTK_Binaries_Release_ARM64"
133+
$srcPath = "{0}\{1}\Bin\Desktop_2022\ARM64\Release\{1}_arm64.exe" -f $binPath, $exe
134+
Copy-Item -Path $srcPath -Destination "." -ErrorAction Stop
135+
136+
$binPath = Join-Path $tempFolderPath "DirectXTK_Binaries_Release_x64"
137+
$srcPath = "{0}\{1}\Bin\Desktop_2022\x64\Release\{1}.exe" -f $binPath, $exe
138+
Copy-Item -Path $srcPath -Destination "." -ErrorAction Stop
139+
140+
$exe = "MakeSpriteFont"
141+
$srcPath = "{0}\{1}\Bin\Release\{1}.exe" -f $binPath, $exe
142+
Copy-Item -Path $srcPath -Destination "." -ErrorAction Stop

0 commit comments

Comments
 (0)