Added build script to move files out of the Resources folder into the target
This commit is contained in:
parent
54edd950eb
commit
81a4e86498
3 changed files with 34 additions and 0 deletions
32
build.rs
Normal file
32
build.rs
Normal file
|
@ -0,0 +1,32 @@
|
|||
use std::env;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
// The directory of the Cargo manifest of the package that is currently being built.
|
||||
let manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is not defined");
|
||||
|
||||
// The directory where the final binaries will be placed.
|
||||
let profile = env::var("PROFILE").expect("PROFILE is not defined");
|
||||
let out_dir = Path::new(&manifest_dir).join("target").join(profile);
|
||||
|
||||
// The Resources directory.
|
||||
let resources_dir = Path::new(&manifest_dir).join("Resources");
|
||||
|
||||
// Ensure the Resources directory exists.
|
||||
if !resources_dir.exists() {
|
||||
panic!("Resources directory does not exist");
|
||||
}
|
||||
|
||||
// Iterate over each entry in the Resources directory.
|
||||
for entry in fs::read_dir(resources_dir).expect("read_dir call failed") {
|
||||
let entry = entry.expect("entry is invalid");
|
||||
let path = entry.path();
|
||||
if path.is_file() {
|
||||
// The destination path is the output directory plus the file name.
|
||||
let dest_path = out_dir.join(path.file_name().expect("file has no name"));
|
||||
// Copy the file.
|
||||
fs::copy(&path, &dest_path).expect("copy failed");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue