#Requires -Version 5.1
<#
.SYNOPSIS
  Developer build: deps, tests (optional), PyInstaller, copy to Desktop, shortcut.

.DESCRIPTION
  Lighter than release_build.ps1 — skips SBOM/zip/manifest. For daily dev iteration.
  Production releases: use scripts\release_build.ps1 or build_release.bat

.PARAMETER SkipTests
  Skip unittest gate (faster iteration).
#>
[CmdletBinding()]
param([switch]$SkipTests)

$ErrorActionPreference = "Stop"
. "$PSScriptRoot\_build_common.ps1"

$root = Get-RepoRoot
Set-Location $root

$py = Resolve-PythonExe
Write-Host "Using: $py"
& $py -c "import sys; assert sys.version_info >= (3, 10); print(sys.version)"

$ver = Get-ReleaseVersion
Install-BuildDependencies -PythonExe $py -Root $root

if (-not $SkipTests) {
    Invoke-UnitTests -PythonExe $py -Root $root
}

Invoke-StageBundledGost -Root $root
Invoke-GenerateVersionInfo -PythonExe $py -Root $root -Version $ver -Commit (Get-GitCommit)

$exe = Invoke-PyInstallerBuild -PythonExe $py -Root $root
$hashInfo = Write-ExeHashSidecar -ExePath $exe

$desk = [Environment]::GetFolderPath("Desktop")
$deskExe = Join-Path $desk "ProxyChainManager.exe"
Copy-Item -LiteralPath $exe -Destination $deskExe -Force
Copy-Item -LiteralPath $hashInfo.Sidecar -Destination "$deskExe.sha256" -Force
Write-Host "Copied: $deskExe (+ .sha256)"

Write-Host "`n== Desktop shortcut =="
& powershell -NoProfile -ExecutionPolicy Bypass -File (Join-Path $root "scripts\create_desktop_shortcut.ps1")

Write-Host "`nDone. Launch from Desktop: Proxy God.lnk (or ProxyChainManager.exe)"
