GameCult.Geometry.Csg/tools/run_realtimecsg_cpp_perf.ps1
2026-05-07 03:28:33 +01:00

38 lines
1.4 KiB
PowerShell

param(
[string]$OutputPath = ".\experiments\generated\realtimecsg-cpp-perf-latest.jsonl",
[string]$PluginDll = ".\experiments\source-repos\realtime-CSG-for-unity\Plugins\Editor\External\x64\RealtimeCSG[1_559].dll",
[switch]$Health,
[switch]$DebugNative
)
$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $PSScriptRoot
$project = Join-Path $root "tools\realtimecsg_native_bridge"
$resolvedOutput = Join-Path $root $OutputPath
$resolvedDll = Join-Path $root $PluginDll
$releaseDir = Join-Path $project "bin\Release\net10.0"
if (!(Test-Path -LiteralPath $resolvedDll)) {
throw "RealtimeCSG native DLL not found: $resolvedDll"
}
New-Item -ItemType Directory -Force -Path (Split-Path -Parent $resolvedOutput) | Out-Null
dotnet build $project -c Release | Out-Host
if ($LASTEXITCODE -ne 0) {
throw "RealtimeCSG native bridge build failed with exit code $LASTEXITCODE"
}
Copy-Item -LiteralPath $resolvedDll -Destination (Join-Path $releaseDir "RealtimeCSG[1_559].dll") -Force
$bridgeArgs = @($resolvedOutput)
if ($Health) {
$bridgeArgs += "--health"
}
if ($DebugNative) {
$bridgeArgs += "--debug-native"
}
& (Join-Path $releaseDir "RealtimeCsgNativeBridge.exe") @bridgeArgs
if ($LASTEXITCODE -ne 0) {
Remove-Item -LiteralPath $resolvedOutput -ErrorAction SilentlyContinue
throw "RealtimeCSG native bridge failed with exit code $LASTEXITCODE"
}
Get-Content -Path $resolvedOutput