2020-05-12 11:39:54 +01:00
|
|
|
[CmdletBinding()] # Fail on unknown args
|
|
|
|
param (
|
|
|
|
[string]$src,
|
|
|
|
[switch]$nocloseeditor = $false,
|
|
|
|
[switch]$dryrun = $false,
|
|
|
|
[switch]$help = $false
|
|
|
|
)
|
|
|
|
|
|
|
|
function Print-Usage {
|
2022-04-19 12:07:09 +01:00
|
|
|
Write-Output "Steve's Unreal Get Latest Tool"
|
|
|
|
Write-Output " Get latest from repo and build for dev. Will close Unreal editor!"
|
2020-05-12 11:39:54 +01:00
|
|
|
Write-Output "Usage:"
|
2022-04-19 16:42:11 +01:00
|
|
|
Write-Output " ue-get-latest.ps1 [[-src:]sourcefolder] [Options]"
|
2020-05-12 11:39:54 +01:00
|
|
|
Write-Output " "
|
|
|
|
Write-Output " -src : Source folder (current folder if omitted)"
|
|
|
|
Write-Output " : (should be root of project)"
|
2022-04-19 12:07:09 +01:00
|
|
|
Write-Output " -nocloseeditor : Don't close Unreal editor (this will prevent DLL cleanup)"
|
2020-05-12 11:39:54 +01:00
|
|
|
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:"
|
2022-04-19 12:07:09 +01:00
|
|
|
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"
|
2020-05-12 11:39:54 +01:00
|
|
|
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."
|
|
|
|
}
|
|
|
|
|
2020-05-25 09:56:34 +01:00
|
|
|
$isGit = Test-Path .git
|
|
|
|
|
|
|
|
if ($isGit) {
|
2020-06-21 14:35:54 +01:00
|
|
|
git diff --ignore-submodules --no-patch --exit-code > $null
|
2020-05-25 09:56:34 +01:00
|
|
|
$unstagedChanges = ($LASTEXITCODE -ne 0)
|
2020-06-21 14:35:54 +01:00
|
|
|
git diff --ignore-submodules --no-patch --cached --exit-code > $null
|
2020-05-25 09:56:34 +01:00
|
|
|
$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"
|
2020-08-06 17:13:15 +01:00
|
|
|
git stash push -q -m "Saved changes during Get Latest"
|
2020-05-25 09:56:34 +01:00
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
|
|
Write-Output "ERROR: git stash push failed, aborting"
|
|
|
|
exit 5
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-26 11:27:12 +01:00
|
|
|
# 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"
|
2020-08-04 16:02:25 +01:00
|
|
|
|
2020-08-11 11:52:03 +01:00
|
|
|
# Stopped using rebase because it's a PITA when it goes wrong
|
2020-05-25 09:56:34 +01:00
|
|
|
Write-Output "Pulling latest from Git..."
|
2020-08-11 11:52:03 +01:00
|
|
|
git pull --recurse-submodules
|
2020-05-25 09:56:34 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2020-05-12 11:39:54 +01:00
|
|
|
} else {
|
2022-04-19 16:42:11 +01:00
|
|
|
# Support Perforce?
|
2020-05-25 09:56:34 +01:00
|
|
|
|
2022-04-19 16:42:11 +01:00
|
|
|
throw "Get Latest only supports Git right now"
|
2020-05-12 11:39:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Now build
|
2021-05-14 16:13:56 +01:00
|
|
|
$cmdargs = @()
|
2020-05-12 11:39:54 +01:00
|
|
|
if ($nocloseeditor) {
|
2021-05-14 16:13:56 +01:00
|
|
|
$cmdargs += "-nocloseeditor"
|
2020-05-12 11:39:54 +01:00
|
|
|
}
|
|
|
|
if ($dryrun) {
|
2021-05-14 16:13:56 +01:00
|
|
|
$cmdargs += "-dryrun"
|
2020-05-12 11:39:54 +01:00
|
|
|
}
|
|
|
|
# Use Invoke-Expression so we can use a string as options
|
2022-04-19 16:42:11 +01:00
|
|
|
Invoke-Expression "&'$PSScriptRoot/ue-build.ps1' dev $cmdargs"
|
2020-05-12 11:39:54 +01:00
|
|
|
|
2020-05-15 11:38:03 +01:00
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
|
|
throw "Build process failed, see above"
|
|
|
|
}
|
|
|
|
|
2021-05-14 16:13:56 +01:00
|
|
|
# Automatically pull lighting builds, if environment variable defined
|
2022-04-19 12:07:09 +01:00
|
|
|
if ($Env:UESYNCROOT -or $Env:UE4SYNCROOT) {
|
2021-05-14 16:13:56 +01:00
|
|
|
$cmdargs = @()
|
|
|
|
if ($nocloseeditor) {
|
|
|
|
$cmdargs += "-nocloseeditor"
|
|
|
|
}
|
|
|
|
if ($dryrun) {
|
|
|
|
$cmdargs += "-dryrun"
|
|
|
|
}
|
|
|
|
# Use Invoke-Expression so we can use a string as options
|
2022-04-19 16:42:11 +01:00
|
|
|
Invoke-Expression "&'$PSScriptRoot/ue-datasync.ps1' pull $cmdargs"
|
2021-05-14 16:13:56 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-05-12 11:39:54 +01:00
|
|
|
Write-Output "-- Get Latest finished OK --"
|
|
|
|
|
|
|
|
|
|
|
|
} catch {
|
|
|
|
Write-Output "ERROR: $($_.Exception.Message)"
|
|
|
|
$result = 9
|
|
|
|
} finally {
|
|
|
|
if ($src -ne ".") { Pop-Location }
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit $result
|
|
|
|
|