-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.rs
33 lines (31 loc) · 1.08 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
use std::path::Path;
use std::{env, fs, io};
fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> {
fs::create_dir_all(&dst)?;
for entry in fs::read_dir(src)? {
let entry = entry?;
let ty = entry.file_type()?;
if ty.is_dir() {
copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?;
} else {
let content = fs::read_to_string(entry.path())?;
fs::write(dst.as_ref().join(entry.file_name()), content)?;
}
}
Ok(())
}
fn main() {
println!("cargo::rerun-if-changed=scout-lib/");
let scout_dir = match env::var("SCOUT_PATH") {
Ok(s) => Path::new(&s).to_path_buf(),
Err(_) => match env::var("HOME").or_else(|_| env::var("USERPROFILE")) {
Ok(s) => Path::new(&s).join("scout-lang"),
Err(_) => {
println!("HOME or SCOUT_PATH not found. Skipping std lib install");
return;
}
},
};
let path = scout_dir.join("scout-lib").to_owned();
copy_dir_all("scout-lib", path).unwrap();
}