-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathue-bugsplat-upload.ps1
More file actions
184 lines (153 loc) · 6.59 KB
/
Copy pathue-bugsplat-upload.ps1
File metadata and controls
184 lines (153 loc) · 6.59 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# Helper for uploading symbols to Bugsplat
# Put packageconfig.json in your project folder to configure
# See packageconfig_template.json
[CmdletBinding()] # Fail on unknown args
param (
# Explicit version to release
[string]$version,
# Latest version option instead of explicit version
[switch]$latest,
[string]$src,
# Name of variant to upload (optional, uses DefaultVariants from packageconfig.json if unspecified)
[array]$variants,
# Dry-run; does nothing but report what *would* have happened
[switch]$dryrun = $false,
[switch]$help = $false
)
. $PSScriptRoot\inc\platform.ps1
. $PSScriptRoot\inc\packageconfig.ps1
. $PSScriptRoot\inc\projectversion.ps1
. $PSScriptRoot\inc\uproject.ps1
. $PSScriptRoot\inc\ueeditor.ps1
. $PSScriptRoot\inc\filetools.ps1
. $PSScriptRoot\inc\buildcmd.ps1
function Write-Usage {
Write-Output "Steve's Unreal Bugsplat Symbol Upload tool"
Write-Output "Usage:"
Write-Output " ue-bugsplat-upload.ps1 [-src:sourcefolder] [-variants=VariantName] [-test] [-dryrun]"
Write-Output " "
Write-Output " -version:ver : Version to upload; must have been packaged already (or use -latest)"
Write-Output " -latest : Instead of an explicit version, upload one identified in project settings"
Write-Output " -src : Source folder (current folder if omitted), must contain packageconfig.json"
Write-Output " -variants Name1,Name2,Name3"
Write-Output " : Upload only named variants instead of DefaultVariants from packageconfig.json"
Write-Output " -dryrun : Don't perform any actual actions, just report on what you would do"
Write-Output " -help : Print this help"
Write-Output " "
Write-Output "Environment Variables:"
Write-Output " UEINSTALL : Use a specific Unreal install."
Write-Output " : Default is to find one based on project version, under UEROOT"
Write-Output " UEROOT : Parent folder of all binary Unreal installs (detects version). "
Write-Output " : Default C:\Program Files\Epic Games"
Write-Output " "
Write-Output " SYMBOL_UPLOAD_CLIENT_ID : OAuth client ID defined in Bugsplat"
Write-Output " SYMBOL_UPLOAD_CLIENT_SECRET : OAuth secret for Bugsplat"
Write-Output " "
}
$ErrorActionPreference = "Stop"
if ($help) {
Write-Usage
Exit 0
}
if ($src.Length -eq 0) {
$src = "."
Write-Verbose "-src not specified, assuming current directory"
}
if (-not $version -and -not $latest) {
Write-Usage
Write-Output ""
Write-Output "ERROR: You must specify a version or -latest"
Exit 1
}
if ($version -and $latest) {
Write-Usage
Write-Output ""
Write-Output "ERROR: You cannot specify a -version and -latest at the same time"
Exit 1
}
Write-Output "~-~-~ Unreal Bugsplat Helper Start ~-~-~"
try {
# Import config
$config = Read-Package-Config -srcfolder:$src
$projfile = Get-Uproject-Filename -srcfolder:$src -config:$config
$proj = Read-Uproject $projfile
$ueVersion = Get-UE-Version $proj
if ($config.BugsplatDatabase.Length -eq 0) {
Write-Output "BugsplatDatabase is not set in packageconfig.json"
Exit 1
}
if ($config.BugsplatApp.Length -eq 0) {
Write-Output "BugsplatApp is not set in packageconfig.json"
Exit 1
}
if ($latest) {
$version = Get-Project-Version $src
}
if ($variants) {
$variantConfigs = $config.Variants | Where-Object { $_.Name -in $variants }
if ($variantConfigs.Count -ne $variants.Count) {
$unmatchedVariants = $variants | Where-Object { $_ -notin $variantConfigs.Name }
Write-Warning "Variant(s) not found, ignoring: $($unmatchedVariants -join ", ")"
}
} else {
# Use default variants
$variantConfigs = $config.Variants | Where-Object { $_.Name -in $config.DefaultVariants }
}
$hasErrors = $false
foreach ($variantConfig in $variantConfigs) {
# Get source dirs
# PDBs are separate, but we also need to upload the main EXE
$pdbsourcedir = Get-Debug-Symbols-Dir -config:$config -versionNumber:$version -variantName:$variantConfig.Name -ueVersion:$ueVersion
$exesourcedir = Get-Package-Client-Dir -config:$config -versionNumber:$version -variantName:$variantConfig.Name -ueVersion:$ueVersion
if (-not (Test-Path $pdbsourcedir -PathType Container)) {
Write-Error "PDB source folder $pdbsourcedir does not exist, skipping"
$hasErrors = $true
continue
}
Write-Output ""
Write-Output "Variant : $($variantConfig.Name)"
Write-Output "Version : $version"
Write-Output "PDB Folder : $pdbsourcedir"
Write-Output "EXE Folder : $exesourcedir"
Write-Output "Bugsplat DB : $config.BugsplatDatabase"
Write-Output "Bugsplat App : $config.BugsplatApp"
Write-Output ""
$symbolupload = "symbol-upload-windows.exe"
$uploadargs = "-f `"**/*.{pdb,exe,dll}`" -b $($config.BugsplatDatabase) -a $($config.BugsplatApp) -v $version"
if ($dryrun) {
Write-Host "Would run (1): $symbolupload $uploadargs"
Write-Host "In directory $pdbsourcedir"
Write-Host "Would run (2): $symbolupload $uploadargs"
Write-Host "In directory $exesourcedir"
} else {
Write-Verbose "Running $symbolupload $uploadargs (PDBs)"
# symbol-upload uploads from the *current dir*
Push-Location $pdbsourcedir
$proc = Start-Process $symbolupload $uploadargs -PassThru -NoNewWindow | Wait-Process -PassThru
if ($proc.ExitCode -ne 0) {
Pop-Location
$code = $proc.ExitCode
throw "*** Upload exited with code $code, see above"
}
Pop-Location
Write-Verbose "Running $symbolupload $uploadargs (EXEs)"
# symbol-upload uploads from the *current dir*
Push-Location $exesourcedir
$proc = Start-Process $symbolupload $uploadargs -PassThru -NoNewWindow | Wait-Process -PassThru
if ($proc.ExitCode -ne 0) {
Pop-Location
$code = $proc.ExitCode
throw "*** Upload exited with code $code, see above"
}
Pop-Location
}
}
if ($hasErrors) {
throw "Errors occurred, see above"
}
} catch {
Write-Output $_.Exception.Message
Write-Output "~-~-~ Unreal Bugsplat Helper FAILED ~-~-~"
Exit 9
}
Write-Output "~-~-~ Unreal Bugsplat Helper Completed OK ~-~-~"