diff --git a/BUILDING.md b/BUILDING.md index 0a16903..fca481e 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -63,8 +63,10 @@ This build may take a significant amount of time, but can save massive headaches First, the `openvino` feature must be enabled in your Cargo.toml. Next, you must set the `OpenVINO_DIR` environment variable to the path where CMake can find -`OpenVINOConfig.cmake`. -This is usually in the `cmake` directory of the OpenVINO installation. +`OpenVINOConfig.cmake`, and the `OpenVINO_SO_DIR` tothe path where the OpenVINO shared +libraries are located. +The former is usually in the `runtime/cmake` directory of the OpenVINO installation, and the latter +is usually in `runtime/lib/intel64`. If you used the AUR package to install OpenVINO, the location of this file is `/opt/intel/openvino/runtime/cmake`. diff --git a/sys/build.rs b/sys/build.rs index 0861f15..df72e78 100644 --- a/sys/build.rs +++ b/sys/build.rs @@ -9,21 +9,39 @@ use std::path::PathBuf; fn main() { // Fail-fast test for OpenVINO #[cfg(feature = "openvino")] - if let Ok(openvino_dir) = env::var("OpenVINO_DIR") { - // see if we can find OpenVINOConfig.cmake - let openvino_config_path = PathBuf::from(&openvino_dir).join("OpenVINOConfig.cmake"); - if !openvino_config_path.exists() { - panic!( - "Couldn't find OpenVINOConfig.cmake in OpenVINO_DIR. Please set it to the path where `OpenVINOConfig.cmake` can be found.\n\ + { + if let Ok(openvino_dir) = env::var("OpenVINO_DIR") { + // see if we can find OpenVINOConfig.cmake + let openvino_config_path = PathBuf::from(&openvino_dir).join("OpenVINOConfig.cmake"); + if !openvino_config_path.exists() { + panic!( + "Couldn't find OpenVINOConfig.cmake in OpenVINO_DIR. Please set it to the path where `OpenVINOConfig.cmake` can be found.\n\ On Arch Linux, if you installed the AUR package, this path is `/opt/intel/openvino/runtime/cmake/`.\n\ Note the `/cmake/` at the end of the path." + ); + } + } else { + panic!( + "Couldn't find the OpenVINO_DIR environment variable. Please set it to the path where `OpenVINOConfig.cmake` can be found.\n\ + On Arch Linux, if you installed the AUR package, this path is `/opt/intel/openvino/runtime/cmake/`." ); } - } else { - panic!( - "Couldn't find the OpenVINO_DIR environment variable. Please set it to the path where `OpenVINOConfig.cmake` can be found.\n\ - On Arch Linux, if you installed the AUR package, this path is `/opt/intel/openvino/runtime/cmake/`." - ); + + if let Ok(openvino_so_dir) = env::var("OpenVINO_SO_DIR") { + // check if `libopenvino.so` exists in the directory + let openvino_so_path = PathBuf::from(&openvino_so_dir).join("libopenvino.so"); + if !openvino_so_path.exists() { + panic!( + "Couldn't find libopenvino.so in OpenVINO_SO_DIR. Please set it to the path where `libopenvino.so` can be found.\n\ + On Arch Linux, if you installed the AUR package, this path is `/opt/intel/openvino/runtime/lib/intel64/`." + ); + } + } else { + panic!( + "Couldn't find the OpenVINO_SO_DIR environment variable. Please set it to the path where `libopenvino.so` can be found.\n\ + On Arch Linux, if you installed the AUR package, this path is `/opt/intel/openvino/runtime/lib/intel64/`." + ) + } } let target = env::var("TARGET").unwrap(); @@ -66,6 +84,11 @@ fn main() { } } } + #[cfg(feature = "openvino")] + { + println!("cargo:rustc-link-lib=openvino"); + println!("cargo:rustc-link-search={}", env::var("OpenVINO_SO_DIR").unwrap()); + } println!("cargo:rerun-if-changed=wrapper.h"); if env::var("WHISPER_DONT_GENERATE_BINDINGS").is_ok() {