Crates.io | windows_exe_info |
lib.rs | windows_exe_info |
version | 0.4.2 |
source | src |
created_at | 2023-05-06 17:04:47.07664 |
updated_at | 2024-01-24 17:06:06.079352 |
description | A cargo build script library for adding file information to windows executables |
homepage | |
repository | https://github.com/MasterOfRespawn/windows_exe_info |
max_upload_size | |
id | 858634 |
size | 62,586 |
A Cargo
build script library to
handle inclusion of Windows icons, version information and application
manifests without the use of external .rc
files.
Inspired by and using embed_resource.
Use embed_resource when the windres
command is not on PATH.
Generic image format conversion requires imagemagick. Imagemagick needs to be in PATH for the conversion functions to work. If imagemagick is not found, the build script will fail.
The only icon format available without imagemagick is .ico
.
This crate only works on windows as resource scripts are a windows thing. By default it will check whether it is compiling for windows and will ignore linking calls otherwise. Build_cfg is required for cross architecture compilation.
.rc
compilerThe default features are embed_resource
, icon_ico
, icon_placeholder
, versioninfo
and windows_only
windows_only
feature by default to prevent linking against non windows operating systemsicon_xxx
, icon_svg
and icon_xcf
all have been replaced by icon_magick
manifest
feature is now optionaladd this crate to your build-dependencies
In Cargo.toml
# the rest of the [package] section
build = "build.rs"
[build-dependencies]
windows_exe_info = "0.4"
.ico
)In build.rs
extern crate windows_exe_info;
fn main(){
windows_exe_info::icon::icon_ico(std::path::Path::new("PATH/TO/ICON.ico"));
}
In build.rs
choose one of these options
extern crate windows_exe_info;
fn main(){
// simple option 1
windows_exe_info::versioninfo::link_cargo_env();
// simple option 2
windows_exe_info::versioninfo::VersionInfo::from_cargo_env().link().unwrap();
// advanced option
windows_exe_info::versioninfo::VersionInfo::from_cargo_env_ex(
Some("comment"),
Some("company name"),
Some("copyright"),
Some("trademarks")
).link().unwrap();
// these three function calls do effectively the same but are required only once
}
In build.rs
extern crate windows_exe_info;
fn main(){
use windows_exe_info::versioninfo::*;
// Change these attributes as you need
VersionInfo {
file_version: Version(0, 1, 0, 0),
product_version: Version(0, 1, 0, 0),
file_flag_mask: FileFlagMask::Win16,
file_flags: FileFlags {
debug: false,
patched: false,
prerelease: false,
privatebuild: false,
infoinferred: false,
specialbuild: false,
},
file_os: FileOS::Windows32,
file_type: FileType::App,
file_info: vec![FileInfo {
lang: Language::USEnglish,
charset: CharacterSet::Multilingual,
comment: None,
company_name: "".into(),
file_description: "An example build script".into(),
file_version: "0.1.0.0".into(),
internal_name: "example".into(),
legal_copyright: None,
legal_trademarks: None,
original_filename: "example.exe".into(),
product_name: "Example".into(),
product_version: "0.1.0.0".into(),
private_build: None,
special_build: None,
}],
}
.link().unwrap();
}
add the manifest feature in Cargo.toml
windows_exe_info = {version = "0.4", features = ["manifest"]}
In build.rs
extern crate windows_exe_info;
fn main(){
windows_exe_info::manifest::manifest(std::path::Path::new("PATH/TO/MANIFEST.XML"));
}