From a98908f05eab306c3e54820f153de4aa7df41cfe Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Sun, 20 Feb 2022 19:12:40 +0200 Subject: [PATCH] feat: Add a Windows application manifest (#3590) * feat: Add a Windows application manifest Closes #3589 * Enable longPathAware * Switch to winres crate * Only depend on winres on Windows * Switch to cfg attribute --- Cargo.lock | 10 ++++++++++ Cargo.toml | 3 +++ build.rs | 15 +++++++++++++-- starship.exe.manifest | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 starship.exe.manifest diff --git a/Cargo.lock b/Cargo.lock index c59ec412..d78c2090 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1649,6 +1649,7 @@ dependencies = [ "versions", "which", "winapi", + "winres", "yaml-rust", ] @@ -2106,6 +2107,15 @@ version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08cabc9f0066848fef4bc6a1c1668e6efce38b661d2aeec75d18d8617eebb5f1" +[[package]] +name = "winres" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c" +dependencies = [ + "toml", +] + [[package]] name = "winrt-notification" version = "0.5.0" diff --git a/Cargo.toml b/Cargo.toml index 1558e496..93eba138 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,6 +84,9 @@ nix = "0.23.1" [build-dependencies] shadow-rs = "0.8.1" +[target.'cfg(windows)'.build-dependencies] +winres = "0.1.12" + [dev-dependencies] mockall = "0.11" tempfile = "3.2.0" diff --git a/build.rs b/build.rs index 4a0dfc45..f6c76935 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,14 @@ -fn main() -> shadow_rs::SdResult<()> { - shadow_rs::new() +use std::error::Error; + +fn main() -> Result<(), Box> { + shadow_rs::new().map_err(|err| err.to_string())?; + + #[cfg(windows)] + { + let mut res = winres::WindowsResource::new(); + res.set_manifest_file("starship.exe.manifest"); + res.compile()?; + } + + Ok(()) } diff --git a/starship.exe.manifest b/starship.exe.manifest new file mode 100644 index 00000000..32d556ed --- /dev/null +++ b/starship.exe.manifest @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + true + + +