162 lines
8.3 KiB
PowerShell
162 lines
8.3 KiB
PowerShell
[CmdletBinding()]
|
|
param(
|
|
[string]$DataPath = '',
|
|
[string]$IconPath = '',
|
|
[string]$PatchSource = '',
|
|
[string]$AuthHost = '',
|
|
[string]$EnvFile = '',
|
|
[string]$PackagePath = '',
|
|
[string]$BinaryPath = '',
|
|
[string]$VcRuntimePath = '',
|
|
[string]$DlssRuntimePath = '',
|
|
[string]$DlssNoticesPath = '',
|
|
[string]$FsrFrameGenerationRuntimePath = '',
|
|
[string]$FsrFrameGenerationNoticesPath = '',
|
|
[string]$Prefix = 'World of Warcraft 1.12.1',
|
|
[string]$ManifestKey = 'manifest-1.12.1.json',
|
|
[switch]$Publish,
|
|
[switch]$DryRun,
|
|
[switch]$SkipClientBuild
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
$repoRoot = Split-Path $PSScriptRoot -Parent
|
|
if (-not $EnvFile) {
|
|
$EnvFile = Join-Path (Split-Path $repoRoot -Parent) 'MoonWellClientSources\.env'
|
|
}
|
|
if (-not $PackagePath) {
|
|
$PackagePath = Join-Path $repoRoot ('dist\moonwell-' + (Get-Date -Format 'yyyyMMdd-HHmmss'))
|
|
}
|
|
$targetDir = Join-Path $repoRoot 'target'
|
|
$playerBinary = Join-Path $targetDir 'release\MoonWell.exe'
|
|
$explicitBinary = [bool]$BinaryPath
|
|
if (-not $BinaryPath) { $BinaryPath = $playerBinary }
|
|
|
|
function Build-Executable([string]$Name, [string[]]$Arguments) {
|
|
$executable = $null
|
|
# Cargo writes progress and ordinary warnings to stderr on a successful build.
|
|
$ErrorActionPreference = 'Continue'
|
|
& cargo @Arguments --target-dir $targetDir --message-format=json-render-diagnostics |
|
|
ForEach-Object {
|
|
if ($_ -like '*"reason":"compiler-artifact"*') {
|
|
$artifact = ConvertFrom-Json $_ -ErrorAction Stop
|
|
if ($artifact.target.name -eq $Name -and $artifact.executable) {
|
|
$executable = [IO.Path]::GetFullPath($artifact.executable)
|
|
}
|
|
}
|
|
}
|
|
if ($LASTEXITCODE -ne 0 -or -not $executable) { throw "$Name build failed." }
|
|
return $executable
|
|
}
|
|
|
|
if ($DlssRuntimePath -or $DlssNoticesPath) {
|
|
if (-not $BinaryPath.EndsWith('.exe', [StringComparison]::OrdinalIgnoreCase)) {
|
|
throw 'DLSS packaging is available for the Windows player.'
|
|
}
|
|
if (-not $DlssRuntimePath -or -not $DlssNoticesPath) {
|
|
throw 'Pass both -DlssRuntimePath (nvngx_dlss.dll) and -DlssNoticesPath.'
|
|
}
|
|
$DlssRuntimePath = (Resolve-Path -LiteralPath $DlssRuntimePath).Path
|
|
$DlssNoticesPath = (Resolve-Path -LiteralPath $DlssNoticesPath).Path
|
|
if ((Split-Path $DlssRuntimePath -Leaf) -ine 'nvngx_dlss.dll' -or
|
|
-not (Test-Path -LiteralPath $DlssRuntimePath -PathType Leaf) -or
|
|
-not (Test-Path -LiteralPath $DlssNoticesPath -PathType Leaf)) {
|
|
throw 'DLSS staging requires the NVIDIA runtime DLL and a notices file.'
|
|
}
|
|
}
|
|
if ($FsrFrameGenerationRuntimePath -or $FsrFrameGenerationNoticesPath) {
|
|
if (-not $BinaryPath.EndsWith('.exe', [StringComparison]::OrdinalIgnoreCase)) {
|
|
throw 'FSR frame generation packaging is available for the Windows player.'
|
|
}
|
|
if (-not $FsrFrameGenerationRuntimePath -or -not $FsrFrameGenerationNoticesPath) {
|
|
throw 'Pass both -FsrFrameGenerationRuntimePath (amd_fidelityfx_vk.dll from SDK 1.1.4) and -FsrFrameGenerationNoticesPath.'
|
|
}
|
|
$FsrFrameGenerationRuntimePath = (Resolve-Path -LiteralPath $FsrFrameGenerationRuntimePath).Path
|
|
$FsrFrameGenerationNoticesPath = (Resolve-Path -LiteralPath $FsrFrameGenerationNoticesPath).Path
|
|
if ((Split-Path $FsrFrameGenerationRuntimePath -Leaf) -ine 'amd_fidelityfx_vk.dll' -or
|
|
-not (Test-Path -LiteralPath $FsrFrameGenerationRuntimePath -PathType Leaf) -or
|
|
-not (Test-Path -LiteralPath $FsrFrameGenerationNoticesPath -PathType Leaf)) {
|
|
throw 'FSR frame generation staging requires the AMD Vulkan runtime and a notices file.'
|
|
}
|
|
}
|
|
if ($BinaryPath.EndsWith('.exe', [StringComparison]::OrdinalIgnoreCase)) {
|
|
if (-not $VcRuntimePath) {
|
|
$vswherePath = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
|
|
$vsInstall = (& $vswherePath -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath).Trim()
|
|
if ($LASTEXITCODE -ne 0 -or -not $vsInstall) { throw 'Visual Studio C++ runtime was not found; pass -VcRuntimePath.' }
|
|
$redistVersion = Get-ChildItem -LiteralPath (Join-Path $vsInstall 'VC\Redist\MSVC') -Directory |
|
|
Where-Object { $_.Name -match '^\d+\.\d+\.\d+$' } |
|
|
Sort-Object { [version]$_.Name } -Descending | Select-Object -First 1
|
|
$VcRuntimePath = Join-Path $redistVersion.FullName 'x64\Microsoft.VC143.CRT'
|
|
}
|
|
if (-not (Test-Path -LiteralPath (Join-Path $VcRuntimePath 'vcruntime140.dll') -PathType Leaf)) {
|
|
throw 'The x64 Visual C++ redistributable vcruntime140.dll was not found.'
|
|
}
|
|
}
|
|
if (-not $DataPath -or -not $AuthHost) {
|
|
throw 'Pass -DataPath pointing to WoW 1.12.1 Data and -AuthHost host[:port]. WOW_HOME from the old .env is deliberately not used.'
|
|
}
|
|
if ($Publish -and $DryRun) { throw 'Choose -Publish or -DryRun.' }
|
|
if (Test-Path -LiteralPath $PackagePath) { throw 'PackagePath already exists; choose a new staging directory.' }
|
|
if (($Publish -or $DryRun) -and -not (Test-Path -LiteralPath $EnvFile -PathType Leaf)) {
|
|
throw 'Deployment .env was not found.'
|
|
}
|
|
|
|
Push-Location $repoRoot
|
|
try {
|
|
if (-not $SkipClientBuild) {
|
|
$embeddedIcon = Join-Path $repoRoot 'crates\moonwell\assets\moonwell.ico'
|
|
if ($IconPath) {
|
|
$sourceIcon = (Resolve-Path -LiteralPath $IconPath).Path
|
|
New-Item -ItemType Directory -Path (Split-Path $embeddedIcon -Parent) -Force | Out-Null
|
|
if ($sourceIcon -ne $embeddedIcon) { Copy-Item -LiteralPath $sourceIcon -Destination $embeddedIcon }
|
|
}
|
|
if (-not (Test-Path -LiteralPath $embeddedIcon -PathType Leaf)) {
|
|
throw 'Provide the MoonWell icon with -IconPath or place it in crates/moonwell/assets/moonwell.ico.'
|
|
}
|
|
$playerArgs = @('build', '-p', 'moonwell', '--release', '--no-default-features', '--locked')
|
|
if ($DlssRuntimePath) { $playerArgs += @('--features', 'dlss') }
|
|
if ($FsrFrameGenerationRuntimePath) { $playerArgs += @('--features', 'frame-generation') }
|
|
$builtPlayer = Build-Executable 'MoonWell' $playerArgs
|
|
if (-not $explicitBinary) { $BinaryPath = $builtPlayer }
|
|
if (($DlssRuntimePath -or $FsrFrameGenerationRuntimePath) -and [IO.Path]::GetFullPath($BinaryPath) -ne $builtPlayer) {
|
|
throw 'Build and stage the same executable, or pass -SkipClientBuild for a prebuilt executable with the runtime feature enabled.'
|
|
}
|
|
}
|
|
|
|
$toolPath = Build-Executable 'moonwell-deploy' @('build', '-p', 'moonwell-deploy', '--release', '--locked')
|
|
$stageArguments = @('stage', '--binary', $BinaryPath, '--data', $DataPath,
|
|
'--output', $PackagePath, '--auth-host', $AuthHost)
|
|
if ($PatchSource) { $stageArguments += @('--source', $PatchSource) }
|
|
& $toolPath @stageArguments
|
|
if ($LASTEXITCODE -ne 0) { throw 'Package staging failed.' }
|
|
if ($BinaryPath.EndsWith('.exe', [StringComparison]::OrdinalIgnoreCase)) {
|
|
Copy-Item -LiteralPath (Join-Path $VcRuntimePath 'vcruntime140.dll') -Destination (Join-Path $PackagePath 'vcruntime140.dll')
|
|
}
|
|
if ($DlssRuntimePath) {
|
|
Copy-Item -LiteralPath $DlssRuntimePath -Destination (Join-Path $PackagePath 'nvngx_dlss.dll')
|
|
Copy-Item -LiteralPath $DlssNoticesPath -Destination (Join-Path $PackagePath 'NVIDIA-DLSS-NOTICES.txt')
|
|
}
|
|
if ($FsrFrameGenerationRuntimePath) {
|
|
Copy-Item -LiteralPath $FsrFrameGenerationRuntimePath -Destination (Join-Path $PackagePath 'amd_fidelityfx_vk.dll')
|
|
Copy-Item -LiteralPath $FsrFrameGenerationNoticesPath -Destination (Join-Path $PackagePath 'AMD-FIDELITYFX-NOTICES.txt')
|
|
}
|
|
|
|
# The local inventory lives outside the package, so it cannot list itself.
|
|
$inventoryPath = $PackagePath + '.manifest.json'
|
|
& $toolPath manifest --dir $PackagePath --output $inventoryPath
|
|
if ($LASTEXITCODE -ne 0) { throw 'Manifest generation failed.' }
|
|
|
|
if ($Publish -or $DryRun) {
|
|
$publishArguments = @('publish', '--dir', $PackagePath, '--env-file', $EnvFile,
|
|
'--prefix', $Prefix, '--manifest-key', $ManifestKey)
|
|
if ($DryRun) { $publishArguments += '--dry-run' }
|
|
& $toolPath @publishArguments
|
|
if ($LASTEXITCODE -ne 0) { throw 'S3 publication failed.' }
|
|
}
|
|
Write-Host "Package: $PackagePath"
|
|
Write-Host "Local manifest: $inventoryPath"
|
|
} finally {
|
|
Pop-Location
|
|
}
|