# build_native_bridge.ps1 - Build daw_vst_bridge.exe (C++ Native Host Bridge) # Run on Windows x64 with VS Build Tools 2022 (C++ workload) installed. # ASCII only (PowerShell 5.1 reads .ps1 without BOM as ANSI). $ErrorActionPreference = "Stop" Set-Location $PSScriptRoot $REPO_ROOT = Resolve-Path (Join-Path $PSScriptRoot "..\..") # ...\SonicForgeStudio $NB_DIR = Join-Path $REPO_ROOT "native_bridge" # 1. vcpkg (bootstrap once; skip if already present) $VCPKG_ROOT = Join-Path $env:USERPROFILE "vcpkg" if (-not (Test-Path (Join-Path $VCPKG_ROOT "vcpkg.exe"))) { Write-Host "== [1/6] Bootstrap vcpkg ==" git clone https://github.com/microsoft/vcpkg $VCPKG_ROOT & (Join-Path $VCPKG_ROOT "bootstrap-vcpkg.bat") -disableMetrics } # 2. vcpkg deps: fluidsynth + sfizz (+ pkgconf so pkg_check_modules may work) Write-Host "== [2/6] vcpkg install fluidsynth sfizz ==" & (Join-Path $VCPKG_ROOT "vcpkg.exe") install fluidsynth sfizz --triplet x64-windows if ($LASTEXITCODE -ne 0) { Write-Host "ERROR: vcpkg install failed" -ForegroundColor Red; exit 1 } # 3. VST3 SDK submodule (Steinberg; NOT in vcpkg) Write-Host "== [3/6] VST3 SDK (submodule) ==" if (-not (Test-Path (Join-Path $NB_DIR "vst3sdk"))) { Push-Location $NB_DIR git submodule add https://github.com/steinbergmedia/vst3sdk.git vst3sdk Pop-Location } # 4. Configure with CMake + vcpkg toolchain (MSVC) Write-Host "== [4/6] CMake configure ==" $BUILD_DIR = Join-Path $NB_DIR "build" New-Item -ItemType Directory -Force $BUILD_DIR | Out-Null cmake -S $NB_DIR -B $BUILD_DIR ` -DCMAKE_TOOLCHAIN_FILE=(Join-Path $VCPKG_ROOT "scripts\buildsystems\vcpkg.cmake") ` -DCMAKE_BUILD_TYPE=Release ` -DVCPKG_TARGET_TRIPLET=x64-windows if ($LASTEXITCODE -ne 0) { Write-Host "ERROR: cmake configure failed" -ForegroundColor Red; exit 1 } # 5. Build Release Write-Host "== [5/6] CMake build ==" cmake --build $BUILD_DIR --config Release if ($LASTEXITCODE -ne 0) { Write-Host "ERROR: cmake build failed" -ForegroundColor Red; exit 1 } # 6. Copy sidecar to Tauri externalBin location Write-Host "== [6/6] Copy to src-tauri\binaries ==" $BIN_DIR = Join-Path $REPO_ROOT "src-tauri\binaries" New-Item -ItemType Directory -Force $BIN_DIR | Out-Null $EXE = Join-Path $BUILD_DIR "Release\daw_vst_bridge.exe" if (-not (Test-Path $EXE)) { Write-Host "ERROR: $EXE not found" -ForegroundColor Red; exit 1 } Copy-Item $EXE (Join-Path $BIN_DIR "daw_vst_bridge-x86_64-pc-windows-msvc.exe") -Force Write-Host "== DONE: daw_vst_bridge.exe copied to src-tauri\binaries =="