grab str.zig path from lib folder relative to exe

This commit is contained in:
Brendan Hansknecht 2022-07-05 10:57:32 -07:00
parent 4220b02913
commit 1dd8b16e12
No known key found for this signature in database
GPG key ID: 0EA784685083E75B

View file

@ -65,6 +65,16 @@ pub fn link(
}
fn find_zig_str_path() -> PathBuf {
// First try using the lib path relative to the executable location.
let exe_relative_str_path = std::env::current_exe()
.ok()
.and_then(|path| Some(path.parent()?.join("lib").join("str.zig")));
if let Some(exe_relative_str_path) = exe_relative_str_path {
if std::path::Path::exists(&exe_relative_str_path) {
return exe_relative_str_path.into();
}
}
let zig_str_path = PathBuf::from("crates/compiler/builtins/bitcode/src/str.zig");
if std::path::Path::exists(&zig_str_path) {