-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
40 lines (34 loc) · 1.53 KB
/
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
28
29
30
31
32
33
34
35
36
37
38
39
40
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(non_camel_case_types)]
use anyhow::*;
use fs_extra::copy_items;
use fs_extra::dir::CopyOptions;
fn main() -> Result<()> {
// This tells cargo to rerun this script if something in /res/ changes.
println!("cargo:rerun-if-changed=res/*");
// Copy the /res/ folder to the output directory.
let mut copyOptions = CopyOptions::new();
copyOptions.overwrite = true;
let pathsToCopy = vec!["res/"];
// Make sure the directories exist.
std::fs::create_dir_all("./target/editor-trace/debug/")?;
std::fs::create_dir_all("./target/editor/debug/")?;
std::fs::create_dir_all("./target/engine-trace/debug/")?;
std::fs::create_dir_all("./target/engine/debug/")?;
std::fs::create_dir_all("./target/editor/release/")?;
std::fs::create_dir_all("./target/engine/release/")?;
// Check if we're in debug or release mode.
if cfg!(debug_assertions) {
// Copy the /res/ folder to the output directory.
copy_items(&pathsToCopy, "./target/editor-trace/debug/", ©Options)?;
copy_items(&pathsToCopy, "./target/editor/debug/", ©Options)?;
copy_items(&pathsToCopy, "./target/engine-trace/debug/", ©Options)?;
copy_items(&pathsToCopy, "./target/engine/debug/", ©Options)?;
} else {
// Copy the /res/ folder to the output directory.
copy_items(&pathsToCopy, "./target/editor/release/", ©Options)?;
copy_items(&pathsToCopy, "./target/engine/release/", ©Options)?;
}
Ok(())
}