-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add directory where asan DLL is to path when running.
- Loading branch information
Showing
4 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,32 @@ | ||
use std::ffi::OsString; | ||
|
||
/// The default target to pass to cargo, to workaround issue #11. | ||
pub fn default_target() -> &'static str { | ||
current_platform::CURRENT_PLATFORM | ||
} | ||
|
||
/// Gets the path to the asan DLL required for the asan instrumented binary to run. | ||
#[cfg(target_env = "msvc")] | ||
pub fn get_asan_path() -> Option<std::path::PathBuf> { | ||
// The asan DLL sits next to cl & link.exe. So grab the parent path. | ||
Some( | ||
cc::windows_registry::find_tool(default_target(), "link.exe")? | ||
.path() | ||
.parent()? | ||
.to_owned(), | ||
) | ||
} | ||
|
||
/// Append a value to the PATH variable | ||
#[cfg(target_env = "msvc")] | ||
pub fn append_to_pathvar(path: std::path::PathBuf) -> Option<OsString> { | ||
use std::env; | ||
|
||
if let Some(current) = env::var_os("PATH") { | ||
let mut current = env::split_paths(¤t).collect::<Vec<_>>(); | ||
current.push(path); | ||
return env::join_paths(current).ok(); | ||
} | ||
|
||
return None; | ||
} |