|
| 1 | +use cfg_if::cfg_if; |
1 | 2 | use std::env;
|
2 | 3 | use std::path::PathBuf;
|
3 | 4 |
|
@@ -85,21 +86,32 @@ const ENV_OPENVINO_INSTALL_DIR: &'static str = "OPENVINO_INSTALL_DIR";
|
85 | 86 | const ENV_OPENVINO_BUILD_DIR: &'static str = "OPENVINO_BUILD_DIR";
|
86 | 87 | const ENV_INTEL_OPENVINO_DIR: &'static str = "INTEL_OPENVINO_DIR";
|
87 | 88 |
|
88 |
| -#[cfg(target_os = "linux")] |
89 |
| -const ENV_LIBRARY_PATH: &'static str = "LD_LIBRARY_PATH"; |
90 |
| -#[cfg(target_os = "macos")] |
91 |
| -const ENV_LIBRARY_PATH: &'static str = "DYLD_LIBRARY_PATH"; |
92 |
| -#[cfg(target_os = "windows")] |
93 |
| -const ENV_LIBRARY_PATH: &'static str = "PATH"; |
| 89 | +cfg_if! { |
| 90 | + if #[cfg(any(target_os = "linux"))] { |
| 91 | + const ENV_LIBRARY_PATH: &'static str = "LD_LIBRARY_PATH"; |
| 92 | + } else if #[cfg(target_os = "macos")] { |
| 93 | + const ENV_LIBRARY_PATH: &'static str = "DYLD_LIBRARY_PATH"; |
| 94 | + } else if #[cfg(target_os = "windows")] { |
| 95 | + const ENV_LIBRARY_PATH: &'static str = "PATH"; |
| 96 | + } else { |
| 97 | + // This may not work but seems like a sane default for target OS' not listed above. |
| 98 | + const ENV_LIBRARY_PATH: &'static str = "LD_LIBRARY_PATH"; |
| 99 | + } |
| 100 | +} |
94 | 101 |
|
95 |
| -#[cfg(any(target_os = "linux", target_os = "macos"))] |
96 |
| -const DEFAULT_INSTALLATION_DIRECTORIES: &'static [&'static str] = |
97 |
| - &["/opt/intel/openvino", "/opt/intel/openvino_2021"]; |
98 |
| -#[cfg(target_os = "windows")] |
99 |
| -const DEFAULT_INSTALLATION_DIRECTORIES: &'static [&'static str] = &[ |
100 |
| - "C:\\Program Files (x86)\\Intel\\openvino", |
101 |
| - "C:\\Program Files (x86)\\Intel\\openvino_2021", |
102 |
| -]; |
| 102 | +cfg_if! { |
| 103 | + if #[cfg(any(target_os = "linux", target_os = "macos"))] { |
| 104 | + const DEFAULT_INSTALLATION_DIRECTORIES: &'static [&'static str] = |
| 105 | + &["/opt/intel/openvino", "/opt/intel/openvino_2021"]; |
| 106 | + } else if #[cfg(target_os = "windows")] { |
| 107 | + const DEFAULT_INSTALLATION_DIRECTORIES: &'static [&'static str] = &[ |
| 108 | + "C:\\Program Files (x86)\\Intel\\openvino", |
| 109 | + "C:\\Program Files (x86)\\Intel\\openvino_2021", |
| 110 | + ]; |
| 111 | + } else { |
| 112 | + const DEFAULT_INSTALLATION_DIRECTORIES: &'static [&'static str] = &[]; |
| 113 | + } |
| 114 | +} |
103 | 115 |
|
104 | 116 | const KNOWN_INSTALLATION_SUBDIRECTORIES: &'static [&'static str] = &[
|
105 | 117 | "deployment_tools/ngraph/lib",
|
|
0 commit comments