Add option to build plugins against different versions of UE

This commit is contained in:
Steve Streeting 2023-06-29 14:40:36 +01:00
parent 27a9659924
commit d764bb32be
3 changed files with 89 additions and 25 deletions

View File

@ -15,6 +15,9 @@ Usage:
-src : Source folder (current folder if omitted)
: (should be root of project)
-allplatforms : Build for all platforms, not just the current one
-allversions : Build for all supported UE versions, not just the current one"
: (specified in pluginconfig.json, only works with lancher-installed UE)"
-uever:5.x.x : Build for a specific UE version, not the current one (launcher only)"
-dryrun : Don't perform any actual actions, just report on what you would do
-help : Print this help
@ -33,7 +36,25 @@ in the root of your plugin, next to the .uplugin file. The options are:
"PackageDir": "C:\\Users\\Steve\\Marketplace",
"BuildDir": "C:\\Users\\Steve\\Builds\\MyPlugin",
"PluginFile": "OptionalPluginFilenameWillDetectInDirOtherwise.uplugin",
"EngineVersions":
[
"5.1.0",
"5.2.0"
]
}
```
Only `BuildDir` is required.
The `-allversions` option only works with Launcher installed engines,
since the path is derived from UEROOT. If using non-Launcher engines, or you
need to change some other environmental options per version (e.g. setting
`LINUX_MULTIARCH_ROOT` environment var), then you're recommended to instead
use the `-uever:` option to build one version at a time, and set the environment
(including `UEINSTALL`) specifically for each version.
This script will, however, handle changing the EngineVersion in the .uplugin
during the build, and resetting it afterwards.

View File

@ -32,3 +32,15 @@ function Get-Uplugin-Filename {
return $projfile
}
}
function Update-UpluginUeVersion {
[string]$srcfolder,
[PluginConfig]$config,
[string]$version
$pluginfile = Get-Uplugin-Filename $srcfolder $config
$plugincontents = (Get-Content $pluginfile) | ConvertFrom-Json
$proj.EngineVersion = $version
$newjson = ($plugincontents | ConvertTo-Json -depth 100)
$newjson | Out-File $pluginfile
}

View File

@ -3,6 +3,8 @@ param (
[string]$mode,
[string]$src,
[switch]$allplatforms = $false,
[switch]$allversions = $false,
[string]$uever = "",
[switch]$nocloseeditor = $false,
[switch]$dryrun = $false,
[switch]$help = $false
@ -23,6 +25,9 @@ function Print-Usage {
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 " "
@ -64,23 +69,39 @@ try {
}
$proj = Read-Uproject $pluginfile
$ueVersion = Get-UE-Version $proj
$ueinstall = Get-UE-Install $ueVersion
$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 : $projfile"
Write-Output "UE Version : $ueVersion"
Write-Output "UE Install : $ueinstall"
Write-Output "Project File : $pluginfile"
Write-Output "UE Version(s) : $($ueVersions -join `", `")"
Write-Output "Output Folder : $($config.BuildDir)"
Write-Output ""
$runUAT = Join-Path $ueinstall "Engine/Build/BatchFiles/RunUAT$batchSuffix"
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=`"$($config.BuildDir)`"") > $null
$argList.Add("-Package=`"$outputDir`"") > $null
$argList.Add("-Rocket") > $null
if (-not $allplatforms) {
@ -97,10 +118,20 @@ try {
} 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 --"