75 lines
2.4 KiB
PowerShell
75 lines
2.4 KiB
PowerShell
#requires -Version 7
|
|
# Top-level Windows release build. Mirrors scripts/macos/build.sh.
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$Root = Resolve-Path (Join-Path $PSScriptRoot '..\..')
|
|
Set-Location $Root
|
|
|
|
if (-not $IsWindows) {
|
|
Write-Error "wrong platform: $($PSVersionTable.OS) - use cargo xtask build"
|
|
exit 1
|
|
}
|
|
|
|
. (Join-Path $PSScriptRoot '_toolchain.ps1')
|
|
$tc = Get-Toolchain
|
|
Initialize-Toolchain $tc
|
|
Write-Host "toolchain: $($tc.Kind)"
|
|
|
|
$env:PROFILE = 'release'
|
|
|
|
$Build = Join-Path $Root 'build'
|
|
$BinDir = Join-Path $Build 'bin\femm'
|
|
|
|
Write-Host 'Building Triangle...'
|
|
& (Join-Path $PSScriptRoot 'build_triangle.ps1')
|
|
|
|
$tri = Join-Path $Root 'build\triangle\triangle.exe'
|
|
if (-not (Test-Path $tri)) { Write-Error "triangle binary missing at $tri"; exit 1 }
|
|
|
|
# femm-app/build.rs embeds this into femm.exe, so it must exist before cargo build.
|
|
$svg = Join-Path $Root 'assets\femm.svg'
|
|
$icoOut = Join-Path $Build 'assets\femm.ico'
|
|
New-Item -ItemType Directory -Force -Path (Split-Path $icoOut) | Out-Null
|
|
if (Test-Path $svg) {
|
|
$magick = Get-Command magick.exe -ErrorAction SilentlyContinue
|
|
if ($magick) {
|
|
& $magick.Source -background none $svg -define icon:auto-resize=16,32,48,64,128,256 $icoOut
|
|
if ($LASTEXITCODE -ne 0) { Write-Warning "magick failed to build $icoOut ($LASTEXITCODE)" }
|
|
} else {
|
|
Write-Warning 'magick not found - femm.exe will be built without an embedded icon'
|
|
}
|
|
}
|
|
|
|
Write-Host 'Building Rust workspace (release)...'
|
|
$cargoArgs = @('build','--release','-p','femm-app','-p','femm-mag-solve')
|
|
if ($tc.CargoTarget) {
|
|
$cargoArgs += @('--target',$tc.CargoTarget)
|
|
}
|
|
& cargo @cargoArgs
|
|
if ($LASTEXITCODE -ne 0) { throw "cargo build failed ($LASTEXITCODE)" }
|
|
|
|
$targetDir = if ($tc.CargoTarget) {
|
|
Join-Path $Root "target\$($tc.CargoTarget)\release"
|
|
} else {
|
|
Join-Path $Root 'target\release'
|
|
}
|
|
$bin = Join-Path $targetDir 'femm.exe'
|
|
$solve = Join-Path $targetDir 'femm-mag-solve.exe'
|
|
foreach ($p in @($bin, $solve)) {
|
|
if (-not (Test-Path $p)) { Write-Error "missing build output: $p"; exit 1 }
|
|
}
|
|
|
|
if (Test-Path $BinDir) { Remove-Item $BinDir -Recurse -Force }
|
|
New-Item -ItemType Directory -Force -Path $BinDir | Out-Null
|
|
|
|
Copy-Item $bin (Join-Path $BinDir 'femm.exe')
|
|
Copy-Item $solve (Join-Path $BinDir 'femm-mag-solve.exe')
|
|
Copy-Item $tri (Join-Path $BinDir 'triangle.exe')
|
|
|
|
if (Test-Path $icoOut) {
|
|
Copy-Item $icoOut (Join-Path $BinDir 'femm.ico')
|
|
}
|
|
|
|
Write-Host "Built: $BinDir"
|