-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.rs
27 lines (22 loc) · 890 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::Path;
use winresource::WindowsResource;
fn main() {
if env::var_os("CARGO_CFG_WINDOWS").is_some() {
WindowsResource::new()
.set_icon("assets/icon.ico")
.compile()
.unwrap();
};
// Retrieve the output directory from the environment variables set by Cargo.
let out_dir = env::var("OUT_DIR").expect("Could not get OUT_DIR");
// Build the destination path for the manifest file.
let dest_path = Path::new(&out_dir).join("Rustcraft.exe.manifest");
// Create the file in the destination path.
let mut f = File::create(dest_path).expect("Failed to create file");
// Include the manifest file's bytes and write them to the destination file.
f.write_all(include_bytes!("Rustcraft.exe.manifest"))
.expect("Failed to write to file");
}