@@ -13,16 +13,36 @@ pub fn find(library_name: &str) -> Option<PathBuf> {
13
13
library_name,
14
14
env:: consts:: DLL_SUFFIX
15
15
) ;
16
+ log:: info!( "Attempting to find library: {}" , file) ;
17
+
18
+ // We search for the library in various different places and early-return if we find it.
19
+ macro_rules! check_and_return {
20
+ ( $path: expr) => {
21
+ log:: debug!( "Searching in: {}" , $path. display( ) ) ;
22
+ if $path. is_file( ) {
23
+ log:: info!( "Found library at path: {}" , $path. display( ) ) ;
24
+ return Some ( $path) ;
25
+ }
26
+ } ;
27
+ }
16
28
17
29
// Search using the `OPENVINO_INSTALL_DIR` environment variable; this may be set by users of the
18
30
// openvino-rs library.
19
31
if let Some ( install_dir) = env:: var_os ( ENV_OPENVINO_INSTALL_DIR ) {
20
32
let install_dir = PathBuf :: from ( install_dir) ;
21
33
for lib_dir in KNOWN_INSTALLATION_SUBDIRECTORIES {
22
34
let search_path = install_dir. join ( lib_dir) . join ( & file) ;
23
- if search_path. is_file ( ) {
24
- return Some ( search_path) ;
25
- }
35
+ check_and_return ! ( search_path) ;
36
+ }
37
+ }
38
+
39
+ // Search using the `OPENVINO_BUILD_DIR` environment variable; this may be set by users of the
40
+ // openvino-rs library.
41
+ if let Some ( build_dir) = env:: var_os ( ENV_OPENVINO_BUILD_DIR ) {
42
+ let install_dir = PathBuf :: from ( build_dir) ;
43
+ for lib_dir in KNOWN_BUILD_SUBDIRECTORIES {
44
+ let search_path = install_dir. join ( lib_dir) . join ( & file) ;
45
+ check_and_return ! ( search_path) ;
26
46
}
27
47
}
28
48
@@ -32,9 +52,7 @@ pub fn find(library_name: &str) -> Option<PathBuf> {
32
52
let install_dir = PathBuf :: from ( install_dir) ;
33
53
for lib_dir in KNOWN_INSTALLATION_SUBDIRECTORIES {
34
54
let search_path = install_dir. join ( lib_dir) . join ( & file) ;
35
- if search_path. is_file ( ) {
36
- return Some ( search_path) ;
37
- }
55
+ check_and_return ! ( search_path) ;
38
56
}
39
57
}
40
58
@@ -44,9 +62,7 @@ pub fn find(library_name: &str) -> Option<PathBuf> {
44
62
if let Some ( path) = env:: var_os ( ENV_LIBRARY_PATH ) {
45
63
for lib_dir in env:: split_paths ( & path) {
46
64
let search_path = lib_dir. join ( & file) ;
47
- if search_path. is_file ( ) {
48
- return Some ( search_path) ;
49
- }
65
+ check_and_return ! ( search_path) ;
50
66
}
51
67
}
52
68
@@ -58,17 +74,15 @@ pub fn find(library_name: &str) -> Option<PathBuf> {
58
74
{
59
75
for lib_dir in KNOWN_INSTALLATION_SUBDIRECTORIES {
60
76
let search_path = default_dir. join ( lib_dir) . join ( & file) ;
61
- if search_path. is_file ( ) {
62
- return Some ( search_path) ;
63
- }
77
+ check_and_return ! ( search_path) ;
64
78
}
65
79
}
66
80
67
81
None
68
82
}
69
83
70
84
const ENV_OPENVINO_INSTALL_DIR : & ' static str = "OPENVINO_INSTALL_DIR" ;
71
-
85
+ const ENV_OPENVINO_BUILD_DIR : & ' static str = "OPENVINO_BUILD_DIR" ;
72
86
const ENV_INTEL_OPENVINO_DIR : & ' static str = "INTEL_OPENVINO_DIR" ;
73
87
74
88
#[ cfg( target_os = "linux" ) ]
@@ -95,6 +109,12 @@ const KNOWN_INSTALLATION_SUBDIRECTORIES: &'static [&'static str] = &[
95
109
"deployment_tools/inference_engine/external/tbb/lib" ,
96
110
] ;
97
111
112
+ const KNOWN_BUILD_SUBDIRECTORIES : & ' static [ & ' static str ] = & [
113
+ "bin/intel64/Debug/lib" ,
114
+ "bin/intel64/Release/lib" ,
115
+ "inference-engine/temp/tbb/lib" ,
116
+ ] ;
117
+
98
118
#[ cfg( test) ]
99
119
mod test {
100
120
use super :: * ;
@@ -103,6 +123,7 @@ mod test {
103
123
/// system.
104
124
#[ test]
105
125
fn find_inference_engine_c_api_locally ( ) {
126
+ pretty_env_logger:: init ( ) ;
106
127
assert ! ( find( "inference_engine_c_api" ) . is_some( ) ) ;
107
128
}
108
129
}
0 commit comments