diff --git a/sys/Cargo.toml b/sys/Cargo.toml index 3417775..ae115da 100644 --- a/sys/Cargo.toml +++ b/sys/Cargo.toml @@ -14,3 +14,5 @@ links = "whisper" [build-dependencies] bindgen = "0.64" +tempfile = "3.3.0" +dircpy = "0.3.14" diff --git a/sys/build.rs b/sys/build.rs index 56647ce..95cba9d 100644 --- a/sys/build.rs +++ b/sys/build.rs @@ -57,8 +57,16 @@ fn main() { return; } + // copy sources to a temporary directory: in some build systems, the source repo can be read-only + // and the makefile compiles files in-place. + let temp_build_dir = tempfile::tempdir().expect("failed to acquire temporary directory"); + dircpy::CopyBuilder::new("whisper.cpp", &temp_build_dir) + .with_exclude_filter(".git") + .run() + .expect("could not copy whisper.cpp to temporary directory"); + // build libwhisper.a - env::set_current_dir("whisper.cpp").expect("Unable to change directory"); + env::set_current_dir(&temp_build_dir).expect("Unable to change directory"); let code = std::process::Command::new("make") .arg("libwhisper.a") .status()