switch checking for str.zig to be relative to the exectuable

This commit is contained in:
Brendan Hansknecht 2023-04-25 07:39:19 -07:00
parent 28146c939f
commit d47c4616f2
No known key found for this signature in database
GPG key ID: 0EA784685083E75B
2 changed files with 40 additions and 44 deletions

View file

@ -4,36 +4,6 @@ use std::{
process::Command,
};
// get the path of the lib folder
// runtime dependencies like zig files, Windows dylib builds, are put in the lib folder
pub fn get_lib_path() -> Option<PathBuf> {
let exe_relative_str_path_opt = std::env::current_exe().ok();
if let Some(exe_relative_str_path) = exe_relative_str_path_opt {
#[cfg(windows)]
let exe_relative_str_path = strip_windows_prefix(&exe_relative_str_path);
let mut curr_parent_opt = exe_relative_str_path.parent();
// this differs for regular build and nix releases, so we check in multiple spots.
for _ in 0..3 {
if let Some(curr_parent) = curr_parent_opt {
let lib_path = curr_parent.join("lib");
if std::path::Path::exists(&lib_path) {
return Some(lib_path);
} else {
curr_parent_opt = curr_parent.parent();
}
} else {
break;
}
}
}
None
}
#[cfg(windows)]
use std::path::Path;