43 lines
1.3 KiB
PowerShell
43 lines
1.3 KiB
PowerShell
$ErrorActionPreference = "Stop"
|
|
|
|
$Root = Resolve-Path "$PSScriptRoot\..\.."
|
|
Set-Location $Root
|
|
|
|
if ($env:OS -ne "Windows_NT") {
|
|
Write-Error "wrong platform, use cargo xtask build"
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "Building Rust binary (release)..."
|
|
cargo build --release --bin yr_crystals
|
|
|
|
$Bin = Join-Path $Root "target\release\yr_crystals.exe"
|
|
if (-not (Test-Path $Bin)) {
|
|
Write-Error "yr_crystals.exe not found at $Bin"
|
|
exit 1
|
|
}
|
|
|
|
$Build = Join-Path $Root "build"
|
|
$BinDir = Join-Path $Build "bin"
|
|
New-Item -ItemType Directory -Force -Path $BinDir | Out-Null
|
|
Copy-Item $Bin (Join-Path $BinDir "yr_crystals.exe") -Force
|
|
|
|
$Svg = Join-Path $Root "assets\Icon.svg"
|
|
$Magick = Get-Command magick -ErrorAction SilentlyContinue
|
|
if ((Test-Path $Svg) -and $Magick) {
|
|
Write-Host "Generating yr_crystals.ico..."
|
|
$IconDir = Join-Path $Build "icons"
|
|
New-Item -ItemType Directory -Force -Path $IconDir | Out-Null
|
|
$Sizes = 16, 32, 48, 64, 128, 256
|
|
$Pngs = @()
|
|
foreach ($s in $Sizes) {
|
|
$Out = Join-Path $IconDir "icon_$s.png"
|
|
& $Magick.Source -background none -density 384 $Svg -resize ${s}x${s} $Out
|
|
$Pngs += $Out
|
|
}
|
|
& $Magick.Source $Pngs (Join-Path $BinDir "yr_crystals.ico")
|
|
Remove-Item $IconDir -Recurse -Force
|
|
}
|
|
|
|
Write-Host "Built: $BinDir\yr_crystals.exe"
|