-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathGenerate-All.ps1
More file actions
79 lines (70 loc) · 3.06 KB
/
Copy pathGenerate-All.ps1
File metadata and controls
79 lines (70 loc) · 3.06 KB
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
[CmdletBinding()]
param(
[string]$Manifest = '',
[string]$OutputRoot = '',
[string[]]$ModuleId = @(),
[switch]$ProbeOnly
)
$ErrorActionPreference = 'Stop'
$toolRoot = (Resolve-Path $PSScriptRoot).Path
$Manifest = if ([string]::IsNullOrWhiteSpace($Manifest)) {
Join-Path $toolRoot 'engine-banks.json'
} else { $Manifest }
$OutputRoot = if ([string]::IsNullOrWhiteSpace($OutputRoot)) {
Join-Path $toolRoot 'GeneratedBanks'
} else { $OutputRoot }
$generator = Join-Path $toolRoot 'bin/Release/EngineAudioGenerator.exe'
$runtimeRoot = Join-Path $toolRoot 'ThirdParty/engine-sim-runtime'
if (-not (Test-Path -LiteralPath $generator)) {
throw "Generator executable was not found: $generator. Run Build-Generator.ps1 first."
}
$settings = Get-Content -Raw -LiteralPath $Manifest | ConvertFrom-Json
$loadList = ($settings.loads | ForEach-Object { $_.ToString([Globalization.CultureInfo]::InvariantCulture) }) -join ','
New-Item -ItemType Directory -Force -Path $OutputRoot | Out-Null
foreach ($engine in $settings.engines) {
if ($ModuleId.Count -gt 0 -and $ModuleId -notcontains $engine.moduleId) {
continue
}
$preset = Join-Path $toolRoot $engine.preset
if (-not (Test-Path -LiteralPath $preset)) {
throw "Preset was not found: $preset"
}
$arguments = @(
'--preset', $preset,
'--runtime-root', $runtimeRoot,
'--entry', $engine.entry,
'--name', $engine.displayName,
'--module-id', $engine.moduleId,
'--sample-rate', [string]$settings.sampleRate,
'--idle-rpm', [string]$engine.fallbackIdleRpm,
'--rpm-points', [string]$settings.rpmPoints,
'--loads', $loadList,
'--stabilize', $settings.stabilizeSeconds.ToString([Globalization.CultureInfo]::InvariantCulture),
'--capture', $settings.captureSeconds.ToString([Globalization.CultureInfo]::InvariantCulture),
'--start-crank', $settings.startup.crankSeconds.ToString([Globalization.CultureInfo]::InvariantCulture),
'--start-catch', $settings.startup.catchSeconds.ToString([Globalization.CultureInfo]::InvariantCulture),
'--start-settle', $settings.startup.settleSeconds.ToString([Globalization.CultureInfo]::InvariantCulture)
)
if ($null -ne $engine.idleRpm) {
$arguments += @('--force-idle-rpm', [string]$engine.idleRpm)
}
if ($null -ne $engine.rpms -and $engine.rpms.Count -gt 0) {
$rpmList = ($engine.rpms | ForEach-Object { [string]$_ }) -join ','
$arguments += @('--rpms', $rpmList)
}
if ($ProbeOnly) {
$arguments += '--probe'
}
else {
$arguments += @('--output', (Join-Path $OutputRoot $engine.moduleId))
}
Write-Host "[$($engine.moduleId)] $($engine.displayName)" -ForegroundColor Cyan
& $generator @arguments
if ($LASTEXITCODE -ne 0) {
throw "Engine generation failed for $($engine.moduleId) with exit code $LASTEXITCODE"
}
}
Write-Host "Engine banks are ready in $OutputRoot" -ForegroundColor Green
if (-not $ProbeOnly) {
& (Join-Path $toolRoot 'Prune-StaleBanks.ps1') -BankRoot $OutputRoot
}