lyra-wasm-scripting-test/witguest/build.rs

27 lines
788 B
Rust

use std::{fs, io, path::Path};
// Example custom build script.
fn main() {
// Tell Cargo that if the given file changes, to rerun this build script.
println!("cargo::rerun-if-changed=../common-api/wit/");
fs::remove_dir_all("./wit/deps/lyraapi").unwrap();
copy_dir_all("../common-api/wit", "./wit/deps/lyraapi").unwrap();
}
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 {
fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?;
}
}
Ok(())
}