-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.rs
37 lines (27 loc) · 1.03 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
use std::env;
use std::fs;
use std::path::Path;
fn main() {
if std::env::var("DOCS_RS").is_ok() {
return;
}
let project_dir = env::var_os("CARGO_MANIFEST_DIR").unwrap();
let sim_const_file_name = "sim_const.rs";
let sim_api_file_name = "sim_api.rs";
let sim_ik_api_file_name = "sim_ik_api.rs";
let sim_dir = Path::new(&project_dir)
.join("src")
.join("remote_api_objects")
.join("sim");
let assets = Path::new(&project_dir).join("c_transpiler").join("assets");
let files = [sim_ik_api_file_name, sim_const_file_name, sim_api_file_name];
for file in files {
let origin = assets.join(file);
let dest = sim_dir.join(file);
println!("cargo:rerun-if-changed={}", origin.to_string_lossy());
let content =
fs::read_to_string(origin.clone()).unwrap_or_else(|_| panic!("read: {origin:?}"));
fs::write(dest.clone(), content).unwrap_or_else(|_| panic!("write: {dest:?}"));
}
println!("cargo:rerun-if-changed=build.rs");
}