-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathue-cook.ps1
More file actions
142 lines (115 loc) · 4.45 KB
/
Copy pathue-cook.ps1
File metadata and controls
142 lines (115 loc) · 4.45 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
[CmdletBinding()] # Fail on unknown args
param (
[string]$src,
[switch]$nocloseeditor = $false,
[switch]$dryrun = $false,
[switch]$help = $false
)
. $PSScriptRoot\inc\platform.ps1
. $PSScriptRoot\inc\packageconfig.ps1
. $PSScriptRoot\inc\projectversion.ps1
. $PSScriptRoot\inc\uproject.ps1
. $PSScriptRoot\inc\filetools.ps1
function Print-Usage {
Write-Output "Steve's Unreal Cook Tool"
Write-Output "Usage:"
Write-Output " ue-cook.ps1 [[-src:]sourcefolder] [Options]"
Write-Output " "
Write-Output " -src : Source folder (current folder if omitted)"
Write-Output " : (should be root of project)"
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
}
if ($src.Length -eq 0) {
$src = "."
Write-Verbose "-src not specified, assuming current directory"
}
$result = 0
try {
if ($src -ne ".") { Push-Location $src }
Write-Output "-- Cook process starting --"
# Locate Unreal project file
$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."
}
# In PS 6.0+ we could use Split-Path -LeafBase but let's stick with built-in PS 5.1
$uprojname = [System.IO.Path]::GetFileNameWithoutExtension($uprojfile)
if ($dryrun) {
Write-Output "Would cook $uprojname"
} else {
Write-Output "Cooking $uprojname"
}
$uproject = Read-Uproject $uprojfile
$uversion = Get-UE-Version $uproject
$uinstall = Get-UE-Install $uversion
Write-Output "Engine version is $uversion"
try {
$config = Read-Package-Config -srcfolder:$src
$foundmaps = Find-Files -startDir:$(Join-Path $src "Content") -pattern:*.umap -includeByDefault:$config.CookAllMaps -includeBaseNames:$config.MapsIncluded -excludeBaseNames:$config.MapsExcluded
$maps = $foundmaps.BaseNames
} catch {
Write-Output "Couldn't read map list from packageconfig.json, no maps will be cooked"
}
# Test we can find RunUAT
$ueEditorCmd = Get-UEEditorCmd $uversion $uinstall
$runUAT = Join-Path $uinstall "Engine/Build/BatchFiles/RunUAT$batchSuffix"
$absuprojectfile = Resolve-Path $uprojfile
$platform = Get-Platform
$argList = [System.Collections.ArrayList]@()
$argList.Add("-ScriptsForProject=`"$absuprojectfile`"") > $null
$argList.Add("BuildCookRun") > $null
$argList.Add("-skipbuildeditor") > $null
$argList.Add("-nocompileeditor") > $null
#$argList.Add("-installed") > $null # don't think we need this, seems to be detected
$argList.Add("-nop4") > $null
$argList.Add("-project=`"$absuprojectfile`"") > $null
$argList.Add("-cook") > $null
$argList.Add("-skipstage") > $null
$argList.Add("-nocompile") > $null
$argList.Add("-nocompileuat") > $null
if ((Get-Is-UE5 $uversion)) {
$argList.Add("-unrealexe=`"$ueEditorCmd`"") > $null
} else {
$argList.Add("-ue4exe=`"$ueEditorCmd`"") > $null
}
$argList.Add("-platform=$($platform)") > $null
$argList.Add("-target=$($uprojname)") > $null
$argList.Add("-utf8output") > $null
if ($maps.Count) {
$argList.Add("-Map=$($maps -join "+")") > $null
}
if ($dryrun) {
Write-Output ""
Write-Output "Would have run:"
Write-Output "> $runUAT $($argList -join " ")"
Write-Output ""
} else {
$proc = Start-Process $runUAT $argList -PassThru -NoNewWindow | Wait-Process -PassThru
if ($proc.ExitCode -ne 0) {
throw "RunUAT failed!"
}
}
Write-Output "-- Cook process finished OK --"
} catch {
Write-Output "ERROR: $($_.Exception.Message)"
$result = 9
} finally {
if ($src -ne ".") { Pop-Location }
}
Exit $result