From fe8eaa3db617dcd2fed8ab78705d5357c709a9ec Mon Sep 17 00:00:00 2001 From: Steve Streeting Date: Wed, 21 Oct 2020 17:32:56 +0100 Subject: [PATCH] Added Blueprint recompile utility --- ue4-blueprint-recompile.ps1 | 103 ++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 ue4-blueprint-recompile.ps1 diff --git a/ue4-blueprint-recompile.ps1 b/ue4-blueprint-recompile.ps1 new file mode 100644 index 0000000..086a240 --- /dev/null +++ b/ue4-blueprint-recompile.ps1 @@ -0,0 +1,103 @@ +# Blueprint bulk recompile helper +[CmdletBinding()] # Fail on unknown args +param ( + # Optional source folder, assumed current folder + [string]$src, + # Optional subfolder of Content to parse, default "Blueprints" + [string]$bpdir = "Blueprints", + # 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\ueinstall.ps1 +. $PSScriptRoot\inc\filetools.ps1 + +# Include Git tools locking +. $PSScriptRoot\GitScripts\inc\locking.ps1 + +function Write-Usage { + Write-Output "Steve's UE4 Blueprint recompile tool" + Write-Output "Usage:" + Write-Output " ue4-blueprint-recompile.ps1 [-src:sourcefolder] [-bpdir:blueprintdir] [-dryrun]" + Write-Output " " + Write-Output " -src : Source folder (current folder if omitted)" + Write-Output " -bpdir : Path to Blueprints relative to your Content dir, defaults to 'Blueprints'" + 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 " UE4INSTALL : Use a specific UE4 install." + Write-Output " : Default is to find one based on project version, under UE4ROOT" + Write-Output " UE4ROOT : Parent folder of all binary UE4 installs (detects version). " + Write-Output " : Default C:\Program Files\Epic Games" + Write-Output " " +} + +if ($src.Length -eq 0) { + $src = "." + Write-Verbose "-src not specified, assuming current directory" +} + +$ErrorActionPreference = "Stop" + +if ($help) { + Write-Usage + Exit 0 +} + +Write-Output "~-~-~ UE4 Blueprint Recompile Start ~-~-~" + +try { + + $config = Read-Package-Config -srcfolder:$src + $projfile = Get-Uproject-Filename -srcfolder:$src -config:$config + $proj = Read-Uproject $projfile + $ueVersion = Get-UE-Version $proj + $ueinstall = Get-UE-Install $ueVersion + + Write-Output "" + Write-Output "Project File : $projfile" + Write-Output "UE Version : $ueVersion" + Write-Output "UE Install : $ueinstall" + Write-Output "Blueprint Dir : Content/$bpdir" + Write-Output "" + + $bpfullpath = Join-Path $src "Content/$bpdir" -Resolve + + $argList = [System.Collections.ArrayList]@() + $argList.Add("`"$projfile`"") > $null + $argList.Add("-run=ResavePackages") > $null + $argList.Add("-packagefolder=`"$bpfullpath`"") > $null + $argList.Add("-autocheckout") > $null + + $ueEditorCmd = Join-Path $ueinstall "Engine/Binaries/Win64/UE4Editor-Cmd$exeSuffix" + + if ($dryrun) { + Write-Output "Would have run:" + Write-Output "> $ueEditorCmd $($argList -join " ")" + + } else { + $proc = Start-Process $ueEditorCmd $argList -Wait -PassThru -NoNewWindow + if ($proc.ExitCode -ne 0) { + throw "Blueprint recompile build failed!" + } + + } + +} catch { + Write-Output $_.Exception.Message + Write-Output "~-~-~ UE4 Blueprint Recompile FAILED ~-~-~" + Exit 9 + +} + + +Write-Output "~-~-~ UE4 Blueprint Recompile OK ~-~-~" +if (!$dryrun) { + Write-Output "Reminder: You may need to commit and unlock Blueprint files" +}