nabijaczleweli/rust-embed-resource

rust-embed-resource

Cargo build script library to handle compilation and inclusion of Windows resources

A Cargo build script library to handle compilation and inclusion of Windows resources in the most resilient fashion imaginable

Documentation

Quickstart

In your build script, assuming the resource file is called checksums.rc:

Example: Embedding a Windows Manifest

Courtesy of @jpoles1.

The following steps are used to embed a manifest in your compiled rust .exe file. In this example the manifest will cause admin permissions to be requested for the final executable:

  1. Add the following to your cargo.toml:

  2. In your project root directory, add a file named build.rs with the following:

  3. In your project root directory, add a file named app-name-manifest.rc with the following:

  4. In your project root directory, add a file named app-name.exe.manifest with the following:

  5. Build your project!

Credit

In chronological order:

@liigo -- persistency in pestering me and investigating problems where I have failed

@mzji -- MSVC lab rat

@TheCatPlusPlus -- knowledge and providing first iteration of manifest-embedding code

@azyobuzin -- providing code for finding places where RC.EXE could hide

@retep998 -- fixing MSVC support

@SonnyX -- Windows cross-compilation support and testing

@MSxDOS -- finding and supplying RC.EXE its esoteric header include paths

@roblabla -- cross-compilation to Windows MSVC via LLVM-RC

Special thanks

To all who support further development on Patreon, in particular:

  • ThePhD
  • Embark Studios
Issues

Collection of the latest Issues

poliorcetics

poliorcetics

Comment Icon0

I have two resource files

  • The first is used for tests and is on a library liba
  • The second is used for the production binary and is on the binary prodbin

The tests are in several libraries depending on liba

So I have something like:

Previously I could simply compile and due to the define order, it worked (I have a CI test for it): prodbin had its resources and everything else inherited liba's resources

I tried some fixes on my side in terms of file name and such, but nothing worked so I cannot updated to the new version 1.7.2. Using compile_for didn't work either.

Trying to detect to only build liba's resources when testing doesn't work because liba has no idea what it is built for (cargo does not give such information, to avoid dependencies affecting their build output based on the end product in hidden ways)

segevfiner

segevfiner

question
Comment Icon2

In order for cargo to correctly rebuild when the manifest or resources change, you need to output cargo:rerun-if-changed. This needs to be output for both the resource script and the resources it embeds. Getting the list of resources might be a bit more tricky as it requires cooperation from the resource compiler similar to how you can request Makefile dependencies from gcc or parse cl output for includes.

nabijaczleweli

nabijaczleweli

bug
Comment Icon2

As of present, src/windows_msvc.rs has an enum Arch { X86, X64 }, and picks the latter iff $TARGET starts with x86_64.

I don't own an aarch64 platform, but if there is someone who does, it'd be lovely if they could figure out what the ??? in {HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots}\bin\*\???\*.exe (find_windows_10_kits_tool()) is or send a PR :)

Versions

Find the latest versions by id

v1.6.3 - Jun 13, 2021

v1.6.2 - Apr 22, 2021

v1.6.1 - Feb 17, 2021

v1.6.0 - Feb 15, 2021

v1.5.1 - Feb 05, 2021

v1.5.0 - Jan 29, 2021

v1.4.1 - Dec 14, 2020

v1.4.0 - Dec 07, 2020

v1.3.4 - Nov 02, 2020

v1.3.3 - Mar 27, 2020

v1.3.2 - Feb 26, 2020

v1.3.1 - Sep 14, 2019

v1.3.0 - Aug 24, 2019

v1.2.1 - Aug 24, 2019

v1.2.0 - Apr 06, 2019

v1.1.4 - Aug 13, 2017

v1.1.3 - Jun 23, 2017

v1.1.2 - May 28, 2017

v1.1.1 - Mar 03, 2017

v1.1.0 - Jan 31, 2017

v0.1.1 - Jan 30, 2017

v0.1.0 - Jan 30, 2017

Information - Updated Jul 26, 2022

Stars: 89
Forks: 14
Issues: 2
IDE

3.5K

Rust Language Server (RLS)

The RLS provides a server that runs in the background, providing IDEs,

Rust Language Server (RLS)

Rust lang bookmarking tool

Rust and Rocket used bookmarking tool for search bar

Rust lang bookmarking tool

Rust Language Security

execrices: RUSTSEC-2021-0001

Rust Language Security

False Positive for rust-lang/rust#83583

The deprecation lint proc_macro_derive_resolution_fallback is intended to catch proc macro generated code that refers to items from parent modules that should not be in scope:

False Positive for rust-lang/rust#83583

rust_icu: low-level rust language bindings for the ICU library

See: The latest version of this file is available at

rust_icu: low-level rust language bindings for the ICU library

Rust lang exercises

Personal tips and drills in my journey as a beginner rustacean

Rust lang exercises

😍 Rust Language

👍 Download and execute rustup

😍 Rust Language

TensorFlow Rust provides idiomatic Rust language

bindings for Documentation

TensorFlow Rust provides idiomatic Rust language

Rust Language Learning material

Rust is blazingly fast systems programming language that prevents segfaults and guarantees thread safety

Rust Language Learning material

leetcode in rust lang

立个flag一年刷完leetcode

leetcode in rust lang
Facebook Instagram Twitter GitHub Dribbble
Privacy