22 stable releases

Uses old Rust 2015

new 1.6.3 Jun 13, 2021
1.6.1 Feb 17, 2021
1.4.1 Dec 14, 2020
1.3.4 Nov 2, 2020
0.1.2 Jan 31, 2017

#4 in Development tools

Download history 5117/week @ 2021-02-24 5142/week @ 2021-03-03 4983/week @ 2021-03-10 5103/week @ 2021-03-17 4603/week @ 2021-03-24 4242/week @ 2021-03-31 5668/week @ 2021-04-07 7443/week @ 2021-04-14 7509/week @ 2021-04-21 7670/week @ 2021-04-28 6850/week @ 2021-05-05 6330/week @ 2021-05-12 5921/week @ 2021-05-19 6354/week @ 2021-05-26 6198/week @ 2021-06-02 4487/week @ 2021-06-09

25,849 downloads per month
Used in 21 crates (17 directly)

MIT license

27KB
368 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.6"
  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

@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

Dependencies

~85KB