Merge remote-tracking branch 'origin/master'
# Conflicts: # sys/src/bindings.rs
This commit is contained in:
commit
2cf2c7f499
11 changed files with 200 additions and 45 deletions
|
|
@ -13,4 +13,4 @@ links = "whisper"
|
|||
[dependencies]
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = "0.60"
|
||||
bindgen = "0.61"
|
||||
|
|
|
|||
50
sys/build.rs
50
sys/build.rs
|
|
@ -8,29 +8,37 @@ fn main() {
|
|||
println!("cargo:rustc-link-lib=static=whisper");
|
||||
println!("cargo:rerun-if-changed=wrapper.h");
|
||||
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header("wrapper.h")
|
||||
.clang_arg("-I./whisper.cpp")
|
||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
|
||||
.generate();
|
||||
if env::var("WHISPER_DONT_GENERATE_BINDINGS").is_ok() {
|
||||
let _: u64 = std::fs::copy(
|
||||
"src/bindings.rs",
|
||||
env::var("OUT_DIR").unwrap() + "/bindings.rs",
|
||||
)
|
||||
.expect("Failed to copy bindings.rs");
|
||||
} else {
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header("wrapper.h")
|
||||
.clang_arg("-I./whisper.cpp")
|
||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
|
||||
.generate();
|
||||
|
||||
match bindings {
|
||||
Ok(b) => {
|
||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
b.write_to_file(out_path.join("bindings.rs"))
|
||||
.expect("Couldn't write bindings!");
|
||||
match bindings {
|
||||
Ok(b) => {
|
||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
b.write_to_file(out_path.join("bindings.rs"))
|
||||
.expect("Couldn't write bindings!");
|
||||
}
|
||||
Err(e) => {
|
||||
println!("cargo:warning=Unable to generate bindings: {}", e);
|
||||
println!("cargo:warning=Using bundled bindings.rs, which may be out of date");
|
||||
// copy src/bindings.rs to OUT_DIR
|
||||
std::fs::copy(
|
||||
"src/bindings.rs",
|
||||
env::var("OUT_DIR").unwrap() + "/bindings.rs",
|
||||
)
|
||||
.expect("Unable to copy bindings.rs");
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
println!("cargo:warning=Unable to generate bindings: {}", e);
|
||||
println!("cargo:warning=Using bundled bindings.rs, which may be out of date");
|
||||
// copy src/bindings.rs to OUT_DIR
|
||||
std::fs::copy(
|
||||
"src/bindings.rs",
|
||||
env::var("OUT_DIR").unwrap() + "/bindings.rs",
|
||||
)
|
||||
.expect("Unable to copy bindings.rs");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// stop if we're on docs.rs
|
||||
if env::var("DOCS_RS").is_ok() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue