-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
26 lines (23 loc) · 917 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
use std::env;
use std::path::Path;
use std::path::PathBuf;
fn main() {
println!("cargo:rerun-if-changed=wokwi-chip.json");
let manifest_dir_string = env::var("CARGO_MANIFEST_DIR").unwrap();
let build_type = env::var("PROFILE").unwrap();
let output_path = PathBuf::from(
Path::new(&manifest_dir_string)
.join("target")
.join("wasm32-unknown-unknown")
.join(build_type),
);
let json_name = format!("{}.json", env::var("CARGO_PKG_NAME").unwrap());
let input_file = Path::new(&manifest_dir_string).join("wokwi-chip.json");
let output_file = Path::new(&output_path).join(json_name);
let res = std::fs::copy(input_file, output_file);
// If failed to copy, print the error and exit with error code
if let Err(e) = res {
println!("cargo:warning=Failed to copy wokwi-chips.json: {}", e);
std::process::exit(1);
}
}