# Script to build and run SecondVoice
Write-Host "Building SecondVoice..." -ForegroundColor Cyan

# Get script directory
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $scriptDir

# Execute build script
& cmd /c .\build_mingw.bat

if ($LASTEXITCODE -eq 0) {
    Write-Host "`nBuild successful! Launching application..." -ForegroundColor Green

    # Check for executable
    if (Test-Path "build\mingw-Release\SecondVoice.exe") {
        Set-Location "build\mingw-Release"
        & .\SecondVoice.exe
    } else {
        Write-Host "Executable not found at expected location" -ForegroundColor Red
    }
} else {
    Write-Host "`nBuild failed!" -ForegroundColor Red
    exit 1
}
