139 lines
5 KiB
PowerShell
139 lines
5 KiB
PowerShell
param(
|
|
[string]$ProjectRoot = 'C:\HyperTwist',
|
|
[string]$ArchiveDirectory = 'C:\HyperTwist\packaged\classic-cube',
|
|
[ValidateSet('Development', 'Shipping')]
|
|
[string]$Configuration = 'Development',
|
|
[string]$CookMap = '/Game/HyperTwistTraining/Maps/L_HyperTwist_ClassicTraining',
|
|
[string[]]$AdditionalCookMaps = @('/Game/HyperTwistTraining/Maps/L_HyperTwist_FollowAlongTraining'),
|
|
[switch]$CleanArchive,
|
|
[switch]$SkipBuild,
|
|
[switch]$SkipLaunch
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$RunUatPath = 'C:\Program Files\Epic Games\UE_5.7\Engine\Build\BatchFiles\RunUAT.bat'
|
|
$UProjectPath = Join-Path $ProjectRoot 'UnrealHyperTwist\UnrealHyperTwist.uproject'
|
|
$LaunchScriptPath = Join-Path $ProjectRoot 'scripts\Launch-HyperTwistClassicCubePackage.ps1'
|
|
$GameTargetReceiptPath = Join-Path $ProjectRoot 'UnrealHyperTwist\Binaries\Win64\UnrealHyperTwist.target'
|
|
$UnrealBuildToolSavedPath = Join-Path $ProjectRoot 'UnrealHyperTwist\Saved\UnrealBuildTool'
|
|
$ClassicCubeBootUrl = $CookMap
|
|
$CookMaps = @($CookMap) + $AdditionalCookMaps | Where-Object { -not [string]::IsNullOrWhiteSpace($_) } | Select-Object -Unique
|
|
$ExpectedClassicCubeMaterialPaths = @(
|
|
(Join-Path $ProjectRoot 'UnrealHyperTwist\Content\HyperTwistTraining\Materials\M_HT_ClassicCubeFaceMaster.uasset'),
|
|
(Join-Path $ProjectRoot 'UnrealHyperTwist\Content\HyperTwistTraining\Materials\MI_HT_ClassicCube_Up.uasset'),
|
|
(Join-Path $ProjectRoot 'UnrealHyperTwist\Content\HyperTwistTraining\Materials\MI_HT_ClassicCube_Down.uasset'),
|
|
(Join-Path $ProjectRoot 'UnrealHyperTwist\Content\HyperTwistTraining\Materials\MI_HT_ClassicCube_Front.uasset'),
|
|
(Join-Path $ProjectRoot 'UnrealHyperTwist\Content\HyperTwistTraining\Materials\MI_HT_ClassicCube_Back.uasset'),
|
|
(Join-Path $ProjectRoot 'UnrealHyperTwist\Content\HyperTwistTraining\Materials\MI_HT_ClassicCube_Left.uasset'),
|
|
(Join-Path $ProjectRoot 'UnrealHyperTwist\Content\HyperTwistTraining\Materials\MI_HT_ClassicCube_Right.uasset'),
|
|
(Join-Path $ProjectRoot 'UnrealHyperTwist\Content\HyperTwistTraining\Materials\MI_HT_ClassicCube_Internal.uasset')
|
|
)
|
|
|
|
function Convert-GameMapPathToContentPath {
|
|
param(
|
|
[string]$RootPath,
|
|
[string]$GameMapPath
|
|
)
|
|
|
|
if (-not $GameMapPath.StartsWith('/Game/'))
|
|
{
|
|
throw "Cook map '$GameMapPath' is not a supported /Game asset path."
|
|
}
|
|
|
|
$RelativeMapPath = $GameMapPath.Substring('/Game/'.Length).Replace('/', '\')
|
|
return Join-Path $RootPath ("UnrealHyperTwist\Content\{0}.umap" -f $RelativeMapPath)
|
|
}
|
|
|
|
function Assert-CookMapExists {
|
|
param(
|
|
[string]$RootPath,
|
|
[string]$GameMapPath
|
|
)
|
|
|
|
$ExpectedMapPath = Convert-GameMapPathToContentPath -RootPath $RootPath -GameMapPath $GameMapPath
|
|
if (-not (Test-Path $ExpectedMapPath))
|
|
{
|
|
throw "Expected cook map '$GameMapPath' was not found at '$ExpectedMapPath'. Run 'scripts\Invoke-HyperTwistClassicCubeMapAuthoring.ps1' first."
|
|
}
|
|
}
|
|
|
|
if (-not (Test-Path $RunUatPath))
|
|
{
|
|
throw "RunUAT was not found at '$RunUatPath'."
|
|
}
|
|
|
|
if (-not (Test-Path $UProjectPath))
|
|
{
|
|
throw "UnrealHyperTwist project file was not found at '$UProjectPath'."
|
|
}
|
|
|
|
foreach ($TargetCookMap in $CookMaps)
|
|
{
|
|
Assert-CookMapExists -RootPath $ProjectRoot -GameMapPath $TargetCookMap
|
|
}
|
|
|
|
foreach ($ExpectedMaterialPath in $ExpectedClassicCubeMaterialPaths)
|
|
{
|
|
if (-not (Test-Path $ExpectedMaterialPath))
|
|
{
|
|
throw "Expected classic-cube material asset was not found at '$ExpectedMaterialPath'. Run 'scripts\\Invoke-HyperTwistClassicCubeMapAuthoring.ps1' first."
|
|
}
|
|
}
|
|
|
|
if ($SkipBuild -and -not (Test-Path $GameTargetReceiptPath))
|
|
{
|
|
throw "SkipBuild was requested, but the packaged-game target receipt was not found at '$GameTargetReceiptPath'. Re-run without -SkipBuild so RunUAT can build the Win64 game target."
|
|
}
|
|
|
|
if ($CleanArchive -and (Test-Path $ArchiveDirectory))
|
|
{
|
|
Remove-Item -LiteralPath $ArchiveDirectory -Recurse -Force
|
|
}
|
|
|
|
New-Item -ItemType Directory -Force -Path $UnrealBuildToolSavedPath | Out-Null
|
|
New-Item -ItemType Directory -Force -Path $ArchiveDirectory | Out-Null
|
|
|
|
$RunUatArguments = @(
|
|
'BuildCookRun',
|
|
"-project=$UProjectPath",
|
|
'-noP4',
|
|
'-platform=Win64',
|
|
"-clientconfig=$Configuration",
|
|
'-cook',
|
|
'-stage',
|
|
'-package',
|
|
'-pak',
|
|
'-archive',
|
|
"-archivedirectory=$ArchiveDirectory",
|
|
"-map=$($CookMaps -join '+')",
|
|
'-unattended',
|
|
'-utf8output'
|
|
)
|
|
|
|
if (-not $SkipBuild)
|
|
{
|
|
$RunUatArguments += '-build'
|
|
}
|
|
|
|
Write-Host "Packaging HyperTwist classic-cube validation lane to '$ArchiveDirectory'..."
|
|
& $RunUatPath @RunUatArguments
|
|
|
|
if ($LASTEXITCODE -ne 0)
|
|
{
|
|
throw "RunUAT packaging failed with exit code $LASTEXITCODE."
|
|
}
|
|
|
|
if (-not $SkipLaunch)
|
|
{
|
|
if (-not (Test-Path $LaunchScriptPath))
|
|
{
|
|
throw "Launch script was not found at '$LaunchScriptPath'."
|
|
}
|
|
|
|
& $LaunchScriptPath -PackageRoot $ArchiveDirectory -MapUrl $ClassicCubeBootUrl
|
|
if ($LASTEXITCODE -ne 0)
|
|
{
|
|
throw "Packaged classic-cube smoke launch failed with exit code $LASTEXITCODE."
|
|
}
|
|
}
|