feat: Windows release packaging
Embed the app icon and version info into the exe, generated from musyx.png by tool/make_ico.ps1, and hide the console window in release builds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c496275101
commit
4b1f0bb8a0
6 files changed
+94
No files matched your search
Generated
+41
@@ -3011,6 +3011,7 @@ dependencies = [
|
||||
"souvlaki",
|
||||
"sys-locale",
|
||||
"tokio",
|
||||
"winresource",
|
||||
"ym-api",
|
||||
]
|
||||
|
||||
@@ -4700,6 +4701,15 @@ dependencies = [
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e7523beb55eece201a2356bee0bbca0d1ab466c14c07703b2e0ee6d42cb0c2c"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_urlencoded"
|
||||
version = "0.7.1"
|
||||
@@ -5361,6 +5371,21 @@ dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "1.1.8+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20489e00e4d8741d6be680764cc12e270655e375a20d1011e844a9c3379e678d"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde_core",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_parser",
|
||||
"toml_writer",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "1.1.2+spec-1.1.0"
|
||||
@@ -5391,6 +5416,12 @@ dependencies = [
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_writer"
|
||||
version = "1.1.3+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06bdbd8cfc056b8d2e2e85f29b56a3bdbecb527cef81eb39e3e7b98af4652770"
|
||||
|
||||
[[package]]
|
||||
name = "tower"
|
||||
version = "0.5.3"
|
||||
@@ -6505,6 +6536,16 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winresource"
|
||||
version = "0.1.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2bc6d36480b829272a5bdabf08e6dca8004761c1da7e35efef800540c66221b"
|
||||
dependencies = [
|
||||
"toml",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen"
|
||||
version = "0.57.1"
|
||||
|
||||
@@ -27,6 +27,9 @@ objc2-foundation = "0.3.2"
|
||||
objc2-app-kit = "0.3.2"
|
||||
block2 = "0.6.2"
|
||||
|
||||
[build-dependencies]
|
||||
winresource = "0.1.34"
|
||||
|
||||
[dev-dependencies]
|
||||
iced_test = "0.14"
|
||||
tokio = { version = "1", features = ["macros", "rt"] }
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
@@ -0,0 +1,12 @@
|
||||
fn main() {
|
||||
// Embed the icon and version info into the Windows executable, so Explorer and the taskbar show them.
|
||||
println!("cargo:rerun-if-changed=assets/icon/musyx.ico");
|
||||
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") {
|
||||
let mut res = winresource::WindowsResource::new();
|
||||
res.set_icon("assets/icon/musyx.ico")
|
||||
.set("ProductName", "Musyx")
|
||||
.set("FileDescription", "Musyx")
|
||||
.set("OriginalFilename", "Musyx.exe");
|
||||
res.compile().expect("failed to embed Windows resources");
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
// No console window behind the app in Windows release builds.
|
||||
#![cfg_attr(all(windows, not(debug_assertions)), windows_subsystem = "windows")]
|
||||
|
||||
mod app;
|
||||
mod covers;
|
||||
mod i18n;
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
# Packs the app icon PNG into a multi-size Windows .ico (PNG-compressed entries).
|
||||
# Usage: powershell -File tool/make_ico.ps1 crates/musyx/assets/icon/musyx.png crates/musyx/assets/icon/musyx.ico
|
||||
param([string]$Src, [string]$Dst)
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
|
||||
$sizes = 16, 20, 24, 32, 40, 48, 64, 128, 256
|
||||
$source = [System.Drawing.Image]::FromFile((Resolve-Path $Src))
|
||||
$images = foreach ($s in $sizes) {
|
||||
$bmp = New-Object System.Drawing.Bitmap $s, $s, ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
|
||||
$g = [System.Drawing.Graphics]::FromImage($bmp)
|
||||
$g.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
|
||||
$g.PixelOffsetMode = [System.Drawing.Drawing2D.PixelOffsetMode]::HighQuality
|
||||
$g.DrawImage($source, 0, 0, $s, $s)
|
||||
$g.Dispose()
|
||||
$ms = New-Object System.IO.MemoryStream
|
||||
$bmp.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png)
|
||||
$bmp.Dispose()
|
||||
, $ms.ToArray()
|
||||
}
|
||||
$source.Dispose()
|
||||
|
||||
$out = New-Object System.IO.MemoryStream
|
||||
$w = New-Object System.IO.BinaryWriter $out
|
||||
$w.Write([uint16]0); $w.Write([uint16]1); $w.Write([uint16]$sizes.Count)
|
||||
$offset = 6 + 16 * $sizes.Count
|
||||
for ($i = 0; $i -lt $sizes.Count; $i++) {
|
||||
$dim = if ($sizes[$i] -ge 256) { 0 } else { $sizes[$i] } # 0 means 256
|
||||
$w.Write([byte]$dim); $w.Write([byte]$dim); $w.Write([byte]0); $w.Write([byte]0)
|
||||
$w.Write([uint16]1); $w.Write([uint16]32)
|
||||
$w.Write([uint32]$images[$i].Length); $w.Write([uint32]$offset)
|
||||
$offset += $images[$i].Length
|
||||
}
|
||||
foreach ($img in $images) { $w.Write($img) }
|
||||
$w.Flush()
|
||||
[System.IO.File]::WriteAllBytes((Join-Path (Get-Location) $Dst), $out.ToArray())
|
||||
Reference in new issue
Block a user