13 stable releases

Uses old Rust 2015

1.3.3 Mar 27, 2020
1.3.1 Sep 14, 2019
1.2.1 Jun 25, 2019
1.1.4 Aug 13, 2017
0.1.2 Jan 31, 2017

#9 in Development tools

Download history 1628/week @ 2020-06-01 2147/week @ 2020-06-08 2438/week @ 2020-06-15 2655/week @ 2020-06-22 2985/week @ 2020-06-29 2635/week @ 2020-07-06 4278/week @ 2020-07-13 3539/week @ 2020-07-20 3790/week @ 2020-07-27 3083/week @ 2020-08-03 2996/week @ 2020-08-10 2763/week @ 2020-08-17 3059/week @ 2020-08-24 3613/week @ 2020-08-31 3287/week @ 2020-09-07 3006/week @ 2020-09-14

7,979 downloads per month
Used in less than 10 crates

MIT license

20KB
257 lines

rust-embed-resource TravisCI build status AppVeyorCI build status Licence Crates.io version

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:

extern crate embed_resource;

fn main() {
    // Compile and link checksums.rc
    embed_resource::compile("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:
[build-dependencies]
embed-resource = "1.3"
  1. In your project root directory, add a file named build.rs with the following:
extern crate embed_resource;
fn main() {
    embed_resource::compile("app-name-manifest.rc");
}
  1. In your project root directory, add a file named app-name-manifest.rc with the following:
#define RT_MANIFEST 24
1 RT_MANIFEST "app-name.exe.manifest"
  1. In your project root directory, add a file named app-name.exe.manifest with the following:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
        <security>
            <requestedPrivileges>
                <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
            </requestedPrivileges>
        </security>
    </trustInfo>
</assembly>
  1. 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

Special thanks

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

  • ThePhD

Dependencies

~53KB