added packaging / bundling
This commit is contained in:
@@ -29,3 +29,24 @@ objc2-app-kit = "0.3"
|
||||
fluent-syntax = "0.12"
|
||||
syn = { version = "2", features = ["full", "visit"] }
|
||||
tempfile = "3"
|
||||
|
||||
[build-dependencies]
|
||||
winresource = "0.1"
|
||||
|
||||
[package.metadata.packager]
|
||||
product-name = "Blogging Desktop Server"
|
||||
identifier = "de.rfc1437.bds2"
|
||||
description = "A desktop application for writing and publishing static blogs."
|
||||
before-packaging-command = "cargo build --release -p bds-ui"
|
||||
icons = [
|
||||
"assets/app-icons/bds.icns",
|
||||
"assets/app-icons/bds.ico",
|
||||
"assets/app-icons/bds.png",
|
||||
]
|
||||
|
||||
[package.metadata.packager.macos]
|
||||
minimum-system-version = "13.0"
|
||||
signing-identity = "-"
|
||||
|
||||
[package.metadata.packager.nsis]
|
||||
installer-icon = "assets/app-icons/bds.ico"
|
||||
|
||||
BIN
crates/bds-ui/assets/app-icons/bds.icns
Normal file
BIN
crates/bds-ui/assets/app-icons/bds.icns
Normal file
Binary file not shown.
BIN
crates/bds-ui/assets/app-icons/bds.ico
Normal file
BIN
crates/bds-ui/assets/app-icons/bds.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
BIN
crates/bds-ui/assets/app-icons/bds.png
Normal file
BIN
crates/bds-ui/assets/app-icons/bds.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 809 KiB |
10
crates/bds-ui/build.rs
Normal file
10
crates/bds-ui/build.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=assets/app-icons/bds.ico");
|
||||
|
||||
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") {
|
||||
winresource::WindowsResource::new()
|
||||
.set_icon("assets/app-icons/bds.ico")
|
||||
.compile()
|
||||
.expect("compile Windows application icon");
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,19 @@
|
||||
#![cfg_attr(target_os = "windows", windows_subsystem = "windows")]
|
||||
|
||||
use bds_ui::BdsApp;
|
||||
|
||||
fn main() -> iced::Result {
|
||||
let icon =
|
||||
iced::window::icon::from_file_data(include_bytes!("../assets/app-icons/bds.png"), None)
|
||||
.expect("bundled application icon must be valid");
|
||||
|
||||
iced::application("bDS", BdsApp::update, BdsApp::view)
|
||||
.subscription(BdsApp::subscription)
|
||||
.theme(|_| iced::Theme::Dark)
|
||||
.window_size((1200.0, 800.0))
|
||||
.window(iced::window::Settings {
|
||||
size: iced::Size::new(1200.0, 800.0),
|
||||
icon: Some(icon),
|
||||
..Default::default()
|
||||
})
|
||||
.run_with(BdsApp::new)
|
||||
}
|
||||
|
||||
41
crates/bds-ui/tests/packaging_assets.rs
Normal file
41
crates/bds-ui/tests/packaging_assets.rs
Normal file
@@ -0,0 +1,41 @@
|
||||
use std::{fs, path::Path};
|
||||
|
||||
const CRATE_DIR: &str = env!("CARGO_MANIFEST_DIR");
|
||||
|
||||
#[test]
|
||||
fn desktop_packages_have_native_icons_and_cargo_commands() {
|
||||
let assets = Path::new(CRATE_DIR).join("assets/app-icons");
|
||||
let png = fs::read(assets.join("bds.png")).expect("Linux PNG icon");
|
||||
let ico = fs::read(assets.join("bds.ico")).expect("Windows ICO icon");
|
||||
let icns = fs::read(assets.join("bds.icns")).expect("macOS ICNS icon");
|
||||
|
||||
assert_eq!(&png[..8], b"\x89PNG\r\n\x1a\n");
|
||||
assert_eq!(u32::from_be_bytes(png[16..20].try_into().unwrap()), 1024);
|
||||
assert_eq!(u32::from_be_bytes(png[20..24].try_into().unwrap()), 1024);
|
||||
assert_eq!(&ico[..4], &[0, 0, 1, 0]);
|
||||
assert!(u16::from_le_bytes(ico[4..6].try_into().unwrap()) >= 6);
|
||||
assert_eq!(&icns[..4], b"icns");
|
||||
|
||||
let manifest = fs::read_to_string(Path::new(CRATE_DIR).join("Cargo.toml")).unwrap();
|
||||
for required in [
|
||||
"[package.metadata.packager]",
|
||||
"assets/app-icons/bds.png",
|
||||
"assets/app-icons/bds.ico",
|
||||
"assets/app-icons/bds.icns",
|
||||
"signing-identity = \"-\"",
|
||||
] {
|
||||
assert!(manifest.contains(required), "missing {required}");
|
||||
}
|
||||
|
||||
let cargo_config = fs::read_to_string(Path::new(CRATE_DIR).join("../../.cargo/config.toml"))
|
||||
.expect("Cargo packaging aliases");
|
||||
for alias in ["bundle-macos", "bundle-windows", "bundle-linux"] {
|
||||
assert!(cargo_config.contains(alias), "missing cargo {alias}");
|
||||
}
|
||||
|
||||
let main = fs::read_to_string(Path::new(CRATE_DIR).join("src/main.rs")).unwrap();
|
||||
assert!(main.contains("assets/app-icons/bds.png"));
|
||||
|
||||
let build = fs::read_to_string(Path::new(CRATE_DIR).join("build.rs")).unwrap();
|
||||
assert!(build.contains("set_icon(\"assets/app-icons/bds.ico\")"));
|
||||
}
|
||||
Reference in New Issue
Block a user