Name Description Size
embed
lib.rs The `embed-manifest` crate provides a straightforward way to embed a Windows manifest in an executable, whatever the build environment and even when cross-compiling, without dependencies on external tools from LLVM or MinGW. This should be called from a [build script][1], as shown below. [1]: https://doc.rust-lang.org/cargo/reference/build-scripts.html On MSVC targets, the manifest file is embedded in the executable by instructing Cargo to pass `/MANIFEST` options to `LINK.EXE`. This requires Cargo from Rust 1.56. On GNU targets, the manifest file is added as a resource in a COFF object file, and Cargo is instructed to link this file into the executable, also using functionality from Rust 1.56. # Usage This crate should be added to the `[build-dependencies]` section in your executable’s `Cargo.toml`: ```toml [build-dependencies] embed-manifest = "1.3.1" ``` In the same directory, create a `build.rs` file to call this crate’s code when building for Windows, and to only run once: ``` use embed_manifest::{embed_manifest, new_manifest}; fn main() { # let tempdir = tempfile::tempdir().unwrap(); # std::env::set_var("OUT_DIR", tempdir.path()); # std::env::set_var("TARGET", "x86_64-pc-windows-gnu"); # std::env::set_var("CARGO_CFG_WINDOWS", ""); if std::env::var_os("CARGO_CFG_WINDOWS").is_some() { embed_manifest(new_manifest("Contoso.Sample")).expect("unable to embed manifest file"); } println!("cargo:rerun-if-changed=build.rs"); } ``` To customise the application manifest, use the methods on it to change things like enabling the segment heap: ``` use embed_manifest::{embed_manifest, new_manifest, manifest::HeapType}; fn main() { # let tempdir = tempfile::tempdir().unwrap(); # std::env::set_var("OUT_DIR", tempdir.path()); # std::env::set_var("TARGET", "x86_64-pc-windows-gnu"); # std::env::set_var("CARGO_CFG_WINDOWS", ""); if std::env::var_os("CARGO_CFG_WINDOWS").is_some() { embed_manifest(new_manifest("Contoso.Sample").heap_type(HeapType::SegmentHeap)) .expect("unable to embed manifest file"); } println!("cargo:rerun-if-changed=build.rs"); } ``` or making it always use legacy single-byte API encoding and only declaring compatibility up to Windows 8.1, without checking whether this is a Windows build: ``` use embed_manifest::{embed_manifest, new_manifest}; use embed_manifest::manifest::{ActiveCodePage::Legacy, SupportedOS::*}; fn main() { # let tempdir = tempfile::tempdir().unwrap(); # std::env::set_var("OUT_DIR", tempdir.path()); # std::env::set_var("TARGET", "x86_64-pc-windows-gnu"); let manifest = new_manifest("Contoso.Sample") .active_code_page(Legacy) .supported_os(Windows7..=Windows81); embed_manifest(manifest).expect("unable to embed manifest file"); println!("cargo:rerun-if-changed=build.rs"); } ``` 5980
manifest