param([string]$GodotPath = "") $ErrorActionPreference = "Stop" $projectRoot = $PSScriptRoot if (-not $GodotPath) { $GodotPath = Join-Path $projectRoot 'tools\godot\Godot_v4.3-stable_win64_console.exe' } if (-not (Test-Path -LiteralPath $GodotPath)) { throw 'Укажите -GodotPath с полным путём к Godot 4 console executable.' } $project = Join-Path $projectRoot 'do-otboy' $output = Join-Path $projectRoot 'builds\Windows' New-Item -ItemType Directory -Force -Path $output | Out-Null $presetPath = Join-Path $project 'export_presets.cfg' $originalPreset = [IO.File]::ReadAllText($presetPath) $localTemplate = Join-Path $projectRoot 'tools\templates\windows_release_x86_64.exe' try { if (Test-Path -LiteralPath $localTemplate) { $newPreset = $originalPreset.Replace('custom_template/release=""', 'custom_template/release="../tools/templates/windows_release_x86_64.exe"') [IO.File]::WriteAllText($presetPath, $newPreset, [Text.UTF8Encoding]::new($false)) } else { $newPreset = $originalPreset.Replace('custom_template/release="../tools/templates/windows_release_x86_64.exe"', 'custom_template/release=""') [IO.File]::WriteAllText($presetPath, $newPreset, [Text.UTF8Encoding]::new($false)) } & $GodotPath --headless --path $project --editor --import --quit if ($LASTEXITCODE -ne 0) { throw 'Godot import failed.' } & $GodotPath --headless --path $project --export-release 'Windows Desktop' (Join-Path $output 'DoOtboy.exe') if ($LASTEXITCODE -ne 0) { throw 'Godot export failed.' } Copy-Item -LiteralPath (Join-Path $projectRoot 'GODOT_LICENSE.txt') -Destination $output -Force Copy-Item -LiteralPath (Join-Path $projectRoot 'README_RU.md') -Destination $output -Force Write-Output "Готово: $output\DoOtboy.exe" } finally { [IO.File]::WriteAllText($presetPath, $originalPreset, [Text.UTF8Encoding]::new($false)) }