-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
29 lines (26 loc) · 883 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
28
29
use anyhow::{anyhow, Ok, Result};
use fs_extra::copy_items;
use fs_extra::dir::CopyOptions;
use std::env;
use std::path::PathBuf;
fn main() -> Result<()> {
println!("cargo:rerun-if-changed=assets");
let out_dir = env::var("OUT_DIR")?;
let target_dir = PathBuf::from(out_dir) // target/debug or target/release
.ancestors()
.nth(3)
.unwrap()
.to_path_buf();
let mut copy_options = CopyOptions::new();
copy_options.overwrite = true;
let paths_to_copy = vec!["assets/"];
copy_items(&paths_to_copy, &target_dir, ©_options)
.map_err(|e| anyhow!("Failed to copy items: {:?}", e))?;
#[cfg(target_arch = "wasm32")]
{
let paths_to_copy = vec!["web"];
copy_items(&paths_to_copy, &target_dir, ©_options)
.map_err(|e| anyhow!("Failed to copy items: {:?}", e))?;
}
Ok(())
}