-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathue-get-latest.ps1
More file actions
148 lines (125 loc) · 4.78 KB
/
ue-get-latest.ps1
File metadata and controls
148 lines (125 loc) · 4.78 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
[CmdletBinding()] # Fail on unknown args
param (
[string]$src,
[switch]$nocloseeditor = $false,
[switch]$dryrun = $false,
[switch]$help = $false
)
function Print-Usage {
Write-Output "Steve's Unreal Get Latest Tool"
Write-Output " Get latest from repo and build for dev. Will close Unreal editor!"
Write-Output "Usage:"
Write-Output " ue-get-latest.ps1 [[-src:]sourcefolder] [Options]"
Write-Output " "
Write-Output " -src : Source folder (current folder if omitted)"
Write-Output " : (should be root of project)"
Write-Output " -nocloseeditor : Don't close Unreal editor (this will prevent DLL cleanup)"
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 " "
}
$ErrorActionPreference = "Stop"
if ($help) {
Print-Usage
Exit 0
}
$result = 0
try {
if ($src -ne ".") { Push-Location $src }
# Make sure we're running in the root of the project
$uprojfile = Get-ChildItem *.uproject | Select-Object -expand Name
if (-not $uprojfile) {
throw "No Unreal project file found in $(Get-Location)! Aborting."
}
if ($uprojfile -is [array]) {
throw "Multiple Unreal project files found in $(Get-Location)! Aborting."
}
$isGit = Test-Path .git
if ($isGit) {
git diff --ignore-submodules --no-patch --exit-code > $null
$unstagedChanges = ($LASTEXITCODE -ne 0)
git diff --ignore-submodules --no-patch --cached --exit-code > $null
$stagedChanges = ($LASTEXITCODE -ne 0)
if ($unstagedChanges -or $stagedChanges) {
if ($dryrun) {
Write-Output "Changes present, would have run 'git stash push'"
} else {
Write-Output "Working copy has changes, saving them in stash"
git stash push -q -m "Saved changes during Get Latest"
if ($LASTEXITCODE -ne 0) {
Write-Output "ERROR: git stash push failed, aborting"
exit 5
}
}
}
# Actually don't clean up anymore, no longer needed
# # Run cleanup tool
# $cleanupargs = @()
# if ($nocloseeditor) {
# $cleanupargs += "-nocloseeditor"
# }
# if ($dryrun) {
# $cleanupargs += "-dryrun"
# }
# # Use Invoke-Expression so we can use a string as options
# Invoke-Expression "&'$PSScriptRoot/ue-cleanup.ps1' $cleanupargs"
# Stopped using rebase because it's a PITA when it goes wrong
Write-Output "Pulling latest from Git..."
# I know Linus says we shouldn't accept the default merge message but pfft
# No artist wan't to see that git merge message pop-up, come on, it's obvious why
git pull --recurse-submodules --no-edit
if ($LASTEXITCODE -ne 0) {
Write-Output "ERROR: git pull failed!"
exit 5
}
if ($unstagedChanges -or $stagedChanges) {
Write-Output "Re-applying your saved changes..."
git stash pop > $null
if ($LASTEXITCODE -ne 0) {
Write-Output "ERROR: Failed to re-apply your changes, resolve manually from stash!"
exit 5
}
}
} else {
# Support Perforce?
throw "Get Latest only supports Git right now"
}
# Now build
$cmdargs = @()
if ($nocloseeditor) {
$cmdargs += "-nocloseeditor"
}
if ($dryrun) {
$cmdargs += "-dryrun"
}
# Use Invoke-Expression so we can use a string as options
Invoke-Expression "&'$PSScriptRoot/ue-build.ps1' dev $cmdargs"
if ($LASTEXITCODE -ne 0) {
throw "Build process failed, see above"
}
# Automatically pull lighting builds, if environment variable defined
if ($Env:UESYNCROOT -or $Env:UE4SYNCROOT) {
$cmdargs = @()
if ($nocloseeditor) {
$cmdargs += "-nocloseeditor"
}
if ($dryrun) {
$cmdargs += "-dryrun"
}
# Use Invoke-Expression so we can use a string as options
Invoke-Expression "&'$PSScriptRoot/ue-datasync.ps1' pull $cmdargs"
}
Write-Output "-- Get Latest finished OK --"
} catch {
Write-Output "ERROR: $($_.Exception.Message)"
$result = 9
} finally {
if ($src -ne ".") { Pop-Location }
}
Exit $result