# Builds extension-reaper as a REAPER extension .dll. $ErrorActionPreference = "Stop" Set-Location $PSScriptRoot $Name = "reaper_extension-reaper.dll" $OutDir = "output" New-Item -ItemType Directory -Force -Path $OutDir | Out-Null # Locate the MSVC toolchain and import its dev environment, so this script # runs from a plain PowerShell session instead of requiring a "Developer # PowerShell for VS" shell. $vswhere = "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" if (-not (Test-Path $vswhere)) { throw "vswhere.exe not found - install Visual Studio Build Tools (C++ workload) first." } $installPath = & $vswhere -latest -products "*" -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath if (-not $installPath) { throw "No MSVC C++ toolchain found via vswhere - install Visual Studio Build Tools (C++ workload) first." } $vcvarsall = Join-Path $installPath "VC\Auxiliary\Build\vcvarsall.bat" $envDump = cmd /c "`"$vcvarsall`" x64 && set" foreach ($line in $envDump) { if ($line -match "^([^=]+)=(.*)$") { Set-Item -Path "Env:$($Matches[1])" -Value $Matches[2] } } cl.exe ` /std:c++17 ` /EHsc ` /LD ` /I ..\vendor\reaper-sdk\sdk ` /I ..\vendor\reaper-sdk\WDL ` /I ..\src ` /Fo"$OutDir\" ` /Fe"$OutDir\$Name" ` ..\src\main.cpp ` ..\src\hello\hello.cpp ` ..\src\tracking\tracking.cpp ` ..\src\socket\socket.cpp ` /link ws2_32.lib Write-Output "Built $OutDir\$Name" $Dest = Join-Path $env:APPDATA "REAPER\UserPlugins\$Name" Copy-Item -Path "$OutDir\$Name" -Destination $Dest -Force Write-Output "Copied to $Dest (restart REAPER to reload)"