Giter Club home page Giter Club logo

rust-embed-resource's Introduction

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

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");

    // 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"]);
    embed_resource::compile_for("assets/uninstaller.rc", &["unins001"]);
}

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.7"
  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
  • Jasper Bekkers

rust-embed-resource's People

Contributors

gabrielmajeri avatar jasper-bekkers avatar mcgoo avatar msxdos avatar nabijaczleweli avatar pravic avatar repi avatar retep998 avatar roblabla avatar selyatin avatar sonnyx avatar thenextman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.