Fix build on Windows
This commit is contained in:
parent
18bb3fb15b
commit
6f03b925cc
1 changed files with 26 additions and 9 deletions
35
sys/build.rs
35
sys/build.rs
|
|
@ -58,9 +58,29 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// build libwhisper.a
|
// build libwhisper.a
|
||||||
env::set_current_dir("whisper.cpp").expect("Unable to change directory");
|
env::set_current_dir("whisper.cpp").expect("Unable to change directory to whisper.cpp");
|
||||||
let code = std::process::Command::new("make")
|
_ = std::fs::remove_dir_all("build");
|
||||||
.arg("libwhisper.a")
|
_ = std::fs::create_dir("build");
|
||||||
|
env::set_current_dir("build").expect("Unable to change directory to whisper.cpp build");
|
||||||
|
|
||||||
|
let code = std::process::Command::new("cmake")
|
||||||
|
.arg("..")
|
||||||
|
.arg("-DCMAKE_BUILD_TYPE=Release")
|
||||||
|
.arg("-DBUILD_SHARED_LIBS=ON")
|
||||||
|
.arg("-DWHISPER_ALL_WARNINGS=OFF")
|
||||||
|
.arg("-DWHISPER_ALL_WARNINGS_3RD_PARTY=OFF")
|
||||||
|
.arg("-DWHISPER_BUILD_TESTS=OFF")
|
||||||
|
.arg("-DWHISPER_BUILD_EXAMPLES=OFF")
|
||||||
|
.status()
|
||||||
|
.expect("Failed to generate build script");
|
||||||
|
if code.code() != Some(0) {
|
||||||
|
panic!("Failed to generate build script");
|
||||||
|
}
|
||||||
|
|
||||||
|
let code = std::process::Command::new("cmake")
|
||||||
|
.arg("--build")
|
||||||
|
.arg(".")
|
||||||
|
.arg("--config Release")
|
||||||
.status()
|
.status()
|
||||||
.expect("Failed to build libwhisper.a");
|
.expect("Failed to build libwhisper.a");
|
||||||
if code.code() != Some(0) {
|
if code.code() != Some(0) {
|
||||||
|
|
@ -68,15 +88,12 @@ fn main() {
|
||||||
}
|
}
|
||||||
// move libwhisper.a to where Cargo expects it (OUT_DIR)
|
// move libwhisper.a to where Cargo expects it (OUT_DIR)
|
||||||
std::fs::copy(
|
std::fs::copy(
|
||||||
"libwhisper.a",
|
"Release/whisper.lib",
|
||||||
format!("{}/libwhisper.a", env::var("OUT_DIR").unwrap()),
|
format!("{}/whisper.lib", env::var("OUT_DIR").unwrap()),
|
||||||
)
|
)
|
||||||
.expect("Failed to copy libwhisper.a");
|
.expect("Failed to copy libwhisper.a");
|
||||||
// clean the whisper build directory to prevent Cargo from complaining during crate publish
|
// clean the whisper build directory to prevent Cargo from complaining during crate publish
|
||||||
std::process::Command::new("make")
|
_ = std::fs::remove_dir_all("build");
|
||||||
.arg("clean")
|
|
||||||
.status()
|
|
||||||
.expect("Failed to clean whisper build directory");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// From https://github.com/alexcrichton/cc-rs/blob/fba7feded71ee4f63cfe885673ead6d7b4f2f454/src/lib.rs#L2462
|
// From https://github.com/alexcrichton/cc-rs/blob/fba7feded71ee4f63cfe885673ead6d7b4f2f454/src/lib.rs#L2462
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue