-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathue-build-plugin.ps1
146 lines (117 loc) · 4.6 KB
/
ue-build-plugin.ps1
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
[CmdletBinding()] # Fail on unknown args
param (
[string]$mode,
[string]$src,
[switch]$allplatforms = $false,
[switch]$allversions = $false,
[string]$uever = "",
[switch]$nocloseeditor = $false,
[switch]$dryrun = $false,
[switch]$help = $false
)
. $PSScriptRoot\inc\platform.ps1
. $PSScriptRoot\inc\pluginconfig.ps1
. $PSScriptRoot\inc\pluginversion.ps1
. $PSScriptRoot\inc\uproject.ps1
. $PSScriptRoot\inc\uplugin.ps1
. $PSScriptRoot\inc\filetools.ps1
function Print-Usage {
Write-Output "Steve's Unreal Plugin Build Tool"
Write-Output "Usage:"
Write-Output " ue-build-plugin.ps1 [[-src:]sourcefolder] [Options]"
Write-Output " "
Write-Output " -src : Source folder (current folder if omitted)"
Write-Output " : (should be root of project)"
Write-Output " -allplatforms : Build for all platforms, not just the current one"
Write-Output " -allversions : Build for all supported UE versions, not just the current one"
Write-Output " : (specified in pluginconfig.json, only works with lancher-installed UE)"
Write-Output " -uever:5.x.x : Build for a specific UE version, not the current one (launcher only)"
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 ($src.Length -eq 0) {
$src = "."
Write-Verbose "-src not specified, assuming current directory"
}
if ($help) {
Print-Usage
Exit 0
}
$result = 0
try {
if ($src -ne ".") { Push-Location $src }
Write-Output "-- Build plugin process starting --"
$config = Read-Plugin-Config -srcfolder:$src
# Locate Unreal project file
$pluginfile = Get-Uplugin-Filename -srcfolder:$src -config:$config
if (-not $pluginfile) {
throw "Not in a uplugin dir!"
}
$proj = Read-Uproject $pluginfile
$origUeVersion = Get-UE-Version $proj
if ($allversions) {
$ueVersions = $config.EngineVersions
} elseif ($uever.Length -gt 0) {
$ueVersions = @($uever)
} else {
$ueVersions = @($origUeVersion)
}
Write-Output ""
Write-Output "Project File : $pluginfile"
Write-Output "UE Version(s) : $($ueVersions -join `", `")"
Write-Output "Output Folder : $($config.BuildDir)"
Write-Output ""
foreach ($ver in $ueVersions) {
Write-Output "Building for UE Version $ver"
$ueinstall = Get-UE-Install $ver
$outputDir = Join-Path $config.BuildDir $ver
# Need to change the version in the plugin while we build
if (-not $dryrun -and ($allversions -or $ueVer.Length -gt 0)) {
Update-UpluginUeVersion $src $config $ver
}
$runUAT = Join-Path $ueinstall "Engine/Build/BatchFiles/RunUAT$batchSuffix"
$argList = [System.Collections.ArrayList]@()
$argList.Add("BuildPlugin") > $null
$argList.Add("-Plugin=`"$pluginfile`"") > $null
$argList.Add("-Package=`"$outputDir`"") > $null
$argList.Add("-Rocket") > $null
if (-not $allplatforms) {
$targetPlatform = Get-Platform
$argList.Add("-TargetPlatforms=$targetPlatform") > $null
}
if ($dryrun) {
Write-Output ""
Write-Output "Would have run:"
Write-Output "> $runUAT $($argList -join " ")"
Write-Output ""
} else {
$proc = Start-Process $runUAT $argList -Wait -PassThru -NoNewWindow
if ($proc.ExitCode -ne 0) {
# Reset the plugin back to the original UE version
if ($allversions -and -not $dryrun) {
Update-UpluginUeVersion $src $config $origUeVersion
}
throw "RunUAT failed!"
}
}
}
# Reset the plugin back to the original UE version
if ($allversions -and -not $dryrun) {
Update-UpluginUeVersion $src $config $origUeVersion
}
Write-Output "-- Build plugin process finished OK --"
} catch {
Write-Output "ERROR: $($_.Exception.Message)"
$result = 9
} finally {
if ($src -ne ".") { Pop-Location }
}
Exit $result