embed_resource

Function compile

Source
pub fn compile<T: AsRef<Path>, Ms: AsRef<OsStr>, Mi: IntoIterator<Item = Ms>>(
    resource_file: T,
    macros: Mi,
)
Expand description

Compile the Windows resource file and update the cargo search path if building for Windows.

On non-Windows non-Windows-cross-compile-target this does nothing, on non-MSVC Windows and Windows cross-compile targets, this chains windres with ar, but on MSVC Windows, this will try its hardest to find RC.EXE in Windows Kits and/or SDK directories, falling back to Jon Blow’s VS discovery script, and on Windows 10 %INCLUDE% will be updated to help RC.EXE find windows.h and friends.

$OUT_DIR is added to the include search path.

Note that this does nothing if building with rustc before 1.50.0 and there’s a library in the crate, since the resource is linked to the library, if any, instead of the binaries.

Since rustc 1.50.0, the resource is linked only to the binaries (unless there are none, in which case it’s also linked to the library).

macros are a list of macros to define, in standard NAME/NAME=VALUE format.

§Examples

In your build script, assuming the crate’s name is “checksums”:

extern crate embed_resource;

fn main() {
    // Compile and link checksums.rc
    embed_resource::compile("checksums.rc", embed_resource::NONE);
}