• Stars
    star
    143
  • Rank 257,007 (Top 6 %)
  • Language
    Rust
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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", embed_resource::NONE);

    // Or, to select a resource file for each binary separately
    embed_resource::compile_for("assets/poke-a-mango.rc", &["poke-a-mango", "poke-a-mango-installer"], &["VERSION=\"0.5.0\""]);
    embed_resource::compile_for("assets/uninstaller.rc", &["unins001"], embed_resource::NONE);
}

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 = "2.2"
  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", embed_resource::NONE);
}
  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!

Errata

If no cargo:rerun-if-changed annotations are generated, Cargo scans the entire build root by default. Because the first step in building a manifest is an unspecified C preprocessor step with-out the ability to generate the equivalent of cc -MD, we do not output said annotation.

If scanning is prohibitively expensive, or you have something else that generates the annotations, you may want to spec the full non-system dependency list for your manifest manually, so:

println!("cargo:rerun-if-changed=app-name-manifest.rc");
embed_resource::compile("app-name-manifest.rc", embed_resource::NONE);

for the above example (cf. #41).

Migration

2.x

Add embed_resource::NONE as the last argument to embed_resource::compile() and embed_resource::compile_for().

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
  • Lars Strojny
  • EvModder

More Repositories

1

cargo-update

A cargo subcommand for checking and applying updates to installed executables
Rust
935
star
2

termimage

Display images in your terminal, kind of
Rust
182
star
3

safe-transmute-rs

A safe-guarded transmute for Rust
Rust
38
star
4

checksums

Tool for making/verifying checksums of directory trees
Rust
36
star
5

BearLibTerminal.rs

BearLibTerminal FFI for Rust
Rust
31
star
6

openalias.rs

Look up and parse OpenAlias data
Rust
20
star
7

tweetr

tweetr is a platform that allows you to create and queue tweets to be shared when YOU want. You create content when you have time and then use FOSS and NOT pay whatever-ridiculous amount of $$$ for posting them automatically.
Rust
18
star
8

wustc

Exampwe of ewwonyenyonyuns code:
Rust
16
star
9

flac-bound

FLAC encoding via libflac FFI
Rust
9
star
10

pb-cpp

Console progress bar for C++
C++
9
star
11

poke-a-mango

What all the kool kidz are playing these days
Rust
7
star
12

hrx.rs

A Rust implementation of the HRX plain text archive format
Rust
6
star
13

whereami-cpp

Locate the current executable and the current module on the file system, in C++
C++
6
star
14

codepage-437

cp437 transcoding for Rust
Rust
5
star
15

registry.pol-rs

Parser for the Windows Registry Policy File format
Rust
5
star
16

gen-epub-book.rs

Generate an ePub book from a simple plaintext descriptor, in Rust
Rust
5
star
17

tackup

Continuously back up your browser tabs
JavaScript
4
star
18

gen-epub-book.cpp

Generate an ePub book from a simple plaintext descriptor, in C++
Shell
4
star
19

blake-rs

Implementation of the BLAKE hash function via FFI for Rust
C
4
star
20

BarbersAndRebarbs

A game in C++ using SFML 2.4
C++
4
star
21

gen-epub-book.js

Generate an ePub book from a simple plaintext descriptor, in JavaScript
JavaScript
3
star
22

gen-epub-book

Generate an ePub book from a simple plaintext descriptor
Awk
3
star
23

rfsapi-rs

Raw Filesystem API for Rust -- enable simpler browsing with ease
Rust
3
star
24

ASMifier

Minecraft mod for DOS 16bit real-mode Assembly programming with (not yet) full FAT16 filesystem emulation.
Scala
3
star
25

goodolddownloads-deobf

Deobfuscate https://goggames.goodolddownloads.com/ links
JavaScript
2
star
26

BearLibTerminal-sys.rs

BearLibTerminal pure FFI
Rust
2
star
27

Cwepper

A minesweeper implementation in C++, hence the name
C++
2
star
28

big-voronoi

Consider: voronoi diagram, but in 3D and in parallel.
C++
2
star
29

dumplingh

Issue/PR exporter for GitHub
Rust
2
star
30

topfig

Assorted config/tooling/lube from the nabtop
Python
2
star
31

babfig

Assorted config/tooling/lube from the babtop
NWScript
2
star
32

progressbar-cpp

C++ wrapper for an easy-to-use C library for displaying text progress bars.
C++
2
star
33

http.deb

Host These Things Please - a basic http server for hosting a folder fast and simply – Debian package
Rust
2
star
34

bidir-map-rs

Bidirectional maps for Rust
Rust
2
star
35

totalcmd-zstd

Total Commander packer plugin for zstd support
C++
2
star
36

nabijaczleweli.github.io

A repo for http://nabijaczleweli.github.io
HTML
2
star
37

PsyduckSublime

Sublime text 3 plugin to add Psyduck
Python
1
star
38

pls-rs

Rust crate for parsing and writing the PLS playlist format
Rust
1
star
39

dotfiles

.
Vim Script
1
star
40

systemd-zram-generator.deb

Systemd unit generator for zram devices – Debian package
Rust
1
star
41

penerator

Generate a secure password over your local network (yes it's a toy, probably don't use it for prod or anything)
C
1
star
42

whereami-rs

whereami for Rust
Rust
1
star
43

Cpp-NBT

Implementation of NBT file format in C++
C++
1
star
44

SublimeLinter-contrib-aspell

Check your spelling with aspell from within Sublime
Python
1
star
45

termimage.deb

Display images in your terminal, kind of – Debian package
Rust
1
star
46

adventure

A strange game.
C++
1
star
47

Cpp-CGOL

Conway's Game of Life, uses the Armadillo linear algebra library.
C++
1
star
48

cimpoler-meta

Header-only C++ compiler metadata extractor
C++
1
star
49

vswhom-sys.rs

Pure FFI to Jon Blow's VS discovery script
C++
1
star
50

dishub

Rust app for posting GitHub activity on Discord.
Rust
1
star
51

libgit2pp

libgit2++ is not yet a solid C++14 wrapper around libgit2 (https://libgit2.github.com)
C++
1
star
52

feembox

What if a feed, but it's a mailbox?
Rust
1
star
53

mcp-mapping-transposer

Translate between two MCP mappings
Rust
1
star
54

BearLibTerminal

Autoimported from https://bitbucket.org/cfyzium/bearlibterminal/
C
1
star
55

gen-epub-book.scala

Generate an ePub book from a simple plaintext descriptor, in Scala
Scala
1
star
56

machine-usable-words

Sets of English words, sorted and segregated for machine consumption
Rust
1
star
57

path.nabijaczleweli.xyz

A page Nat can link to that explains, for every operating system, how to add a folder to your PATH
HTML
1
star
58

voltaire

Pulse a coil to get a bigger voltage, a.k.a. a template embedded project
Makefile
1
star
59

mandalas-rs

A mandala generator using Tonči Juričev-Grgin's method in Rust with a scalable driver
Rust
1
star