Fix PowerShell parse errors in build_windows.ps1 (#110) · unslothai/audio.cpp@b8217a1 · GitHub
Skip to content

Commit b8217a1

Browse files
authored
Fix PowerShell parse errors in build_windows.ps1 (0xShug0#110)
The Windows build script failed at function definition time on every PowerShell version (Windows PowerShell 5.1 and PowerShell 7+), aborting before CMake configure could start. Two issues in scripts/build_windows.ps1: 1. Invalid `return if (...) {...} else {...}` syntax in Find-VsCMake and Find-VsNinja. PowerShell does not allow `return` to be followed by an `if` statement; the parser treats `if` as an unknown command, so both functions fail to define. The script then aborts at `$cmake = Find-VsCMake $vsInstall` with "The term 'if' is not recognized as the name of a cmdlet". Rewritten as `if ($cmd) { return $cmd.Source } else { return "" }`. 2. `$ErrorActionPreference = "Stop"` (combined with StrictMode) turns any native-command stderr line (e.g. a CMake dev warning) into a terminating error, so Invoke-Checked throws before $LASTEXITCODE is checked. The script relies on $LASTEXITCODE for failure detection, so switch to "Continue". Verified on Windows 11, RTX 4090 D (sm_89), VS Build Tools 2022, CUDA 12.8, CMake 4.3.3, Ninja 1.13.2: - Parser check: [Parser]::ParseInput reports 0 errors; Find-VsCMake and Find-VsNinja both define successfully after dot-sourcing. - `scripts/build_windows.ps1 -Preset windows-cuda-release -ConfigureOnly` now reaches `Configuring done`. - `scripts/build_windows.ps1 -Preset windows-cuda-release -Target audiocpp_cli -Jobs 16` builds audiocpp_cli.exe, which runs `--list-loaders` (36 loaders) and a CUDA marblenet_vad request end to end.
1 parent 27d87ba commit b8217a1

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎scripts/build_windows.ps1‎

Lines changed: 3 additions & 3 deletions

0 commit comments

Comments
 (0)