From cf71a23aecacf7418167584a4ea154d7ef4640fb Mon Sep 17 00:00:00 2001 From: hut Date: Fri, 19 Apr 2024 23:47:40 +0200 Subject: [PATCH] embed icon into OutFly.exe --- Cargo.lock | 52 +++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 4 ++++ build/build.rs | 7 ++++++ build/pack.sh | 4 ++-- build/windows/icon.rc | 2 +- 5 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 build/build.rs diff --git a/Cargo.lock b/Cargo.lock index 11fed73..1267088 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1600,6 +1600,19 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +[[package]] +name = "embed-resource" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e62abb876c07e4754fae5c14cafa77937841f01740637e17d78dc04352f32a5e" +dependencies = [ + "cc", + "rustc_version", + "toml", + "vswhom", + "winreg", +] + [[package]] name = "encase" version = "0.7.0" @@ -2774,6 +2787,7 @@ dependencies = [ "bevy", "bevy_embedded_assets", "bevy_xpbd_3d", + "embed-resource", "fastrand", "regex", "serde", @@ -3542,6 +3556,15 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + [[package]] name = "toml_datetime" version = "0.6.5" @@ -3716,6 +3739,26 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "vswhom" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be979b7f07507105799e854203b470ff7c78a1639e330a58f183b5fea574608b" +dependencies = [ + "libc", + "vswhom-sys", +] + +[[package]] +name = "vswhom-sys" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3b17ae1f6c8a2b28506cd96d412eebf83b4a0ff2cbefeeb952f2f9dfa44ba18" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "walkdir" version = "2.5.0" @@ -4416,6 +4459,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + [[package]] name = "x11-dl" version = "2.21.0" diff --git a/Cargo.toml b/Cargo.toml index 6e256bb..0bb2695 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ categories = ["game", "aerospace", "simulation"] keywords = ["game", "space", "3d"] license = "GPL-3.0-only" rust-version = "1.76.0" +build = "build/build.rs" [dependencies] regex = "1" @@ -18,6 +19,9 @@ fastrand = "2.0" serde = "1.0" serde_yaml = "0.9" +[build-dependencies] +embed-resource = "1.6.3" # embedding of .exe metadata + [features] default = ["x11"] dev = ["bevy/dynamic_linking", "bevy/file_watcher"] diff --git a/build/build.rs b/build/build.rs new file mode 100644 index 0000000..206c01d --- /dev/null +++ b/build/build.rs @@ -0,0 +1,7 @@ +fn main() { + let target = std::env::var("TARGET").unwrap(); + if target.contains("windows") { + println!("cargo:warning=Embedding Windows Icon"); + embed_resource::compile("build/windows/icon.rc"); + } +} diff --git a/build/pack.sh b/build/pack.sh index 6b91c41..f045a03 100755 --- a/build/pack.sh +++ b/build/pack.sh @@ -21,10 +21,10 @@ SRCPATH="outfly_v$VERSION" mkdir "$SRCPATH" cp ../README.md "$SRCPATH" -cp ../target/x86_64-pc-windows-gnu/release/outfly.exe "$SRCPATH" +cp ../target/x86_64-pc-windows-gnu/release/outfly.exe "$SRCPATH"/OutFly.exe zip -v -r -9 ../"outfly_v${VERSION}_windows.zip" "$SRCPATH" -rm "$SRCPATH"/outfly.exe +rm "$SRCPATH"/OutFly.exe cp ../target/x86_64-unknown-linux-gnu/release/outfly "$SRCPATH" zip -v -r -9 ../"outfly_v${VERSION}_linux.zip" "$SRCPATH" diff --git a/build/windows/icon.rc b/build/windows/icon.rc index 61c0aef..124e3fd 100644 --- a/build/windows/icon.rc +++ b/build/windows/icon.rc @@ -1 +1 @@ -app_icon ICON "icon.ico" +app_icon ICON "outfly.ico"