39 lines
2.3 KiB
PowerShell
39 lines
2.3 KiB
PowerShell
param(
|
|
[string]$AfterFx = 'C:\Program Files\Adobe\Adobe After Effects 2025\Support Files\AfterFX.com',
|
|
[ValidateSet(4,5,6,7,8)][int]$Version = 8
|
|
)
|
|
$ErrorActionPreference = 'Stop'
|
|
$studioRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
|
$studioScript = if ($Version -eq 4) {
|
|
Join-Path $PSScriptRoot 'make_studio_v4.jsx'
|
|
} else {
|
|
Join-Path $PSScriptRoot 'make_studio_v5.jsx'
|
|
}
|
|
$studioCut = if ($Version -eq 8) { "-16s" } else { "" }
|
|
$studioProject = Join-Path $studioRoot "assets\cinematics\source\EblanGames-workshop-v${Version}$studioCut.aep"
|
|
$studioLog = Join-Path $studioRoot "build\cinematic-v$Version\ae-studio-v$Version.log"
|
|
if (!(Test-Path -LiteralPath $AfterFx)) { throw "After Effects not found: $AfterFx" }
|
|
# AE's CLI did not execute a non-ASCII script path here. An ASCII temp bridge
|
|
# loads the actual repository script with ExtendScript's Unicode File API.
|
|
$studioBridge = Join-Path $env:TEMP "EblanGames_studio_v$($Version)_build.jsx"
|
|
$studioEscaped = -join ($studioScript.Replace('\','/').ToCharArray() | ForEach-Object { '\u{0:x4}' -f [int]$_ })
|
|
Set-Content -LiteralPath $studioBridge -Encoding ascii -Value ('$.global.eblanStudioVersion=' + $Version + '; $.evalFile(new File("' + $studioEscaped + '"));')
|
|
$studioStarted = Get-Date
|
|
$studioAeProcess = Start-Process -FilePath $AfterFx -ArgumentList @('-m','-r',('"' + $studioBridge + '"')) -WindowStyle Hidden -PassThru
|
|
for ($studioAttempt=0; $studioAttempt -lt 45; $studioAttempt++) {
|
|
if ((Test-Path -LiteralPath $studioProject) -and (Test-Path -LiteralPath $studioLog)) {
|
|
$studioProjectInfo = Get-Item -LiteralPath $studioProject
|
|
if ($studioProjectInfo.LastWriteTime -ge $studioStarted -and (Get-Content -LiteralPath $studioLog -Tail 1) -like 'SUCCESS*') {
|
|
# The console wrapper can remain waiting after AE has saved/quit.
|
|
# Stop only the helper process this invocation created.
|
|
if ([IO.Path]::GetExtension($AfterFx) -eq '.com') {
|
|
$studioAeProcess.Refresh()
|
|
if (!$studioAeProcess.HasExited) { Stop-Process -Id $studioAeProcess.Id }
|
|
}
|
|
Write-Output "Saved AE project: $studioProject"
|
|
exit 0
|
|
}
|
|
}
|
|
Start-Sleep -Seconds 1
|
|
}
|
|
throw "AE project was not saved; inspect $studioLog (started PID $($studioAeProcess.Id))."
|