Skip to content

Commit

Permalink
rust: default intercept config added for non-linux os
Browse files Browse the repository at this point in the history
  • Loading branch information
rizsotto committed Jan 18, 2025
1 parent f85263b commit 8dc417a
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions rust/bear/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,19 +222,42 @@ pub enum Intercept {

/// The default intercept mode is varying based on the target operating system.
impl Default for Intercept {
#[cfg(target_os = "linux")]
#[cfg(any(
target_os = "linux",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "dragonfly"
))]
fn default() -> Self {
Intercept::Preload {
path: default_preload_library(),
}
}

#[cfg(not(target_os = "linux"))]
#[cfg(any(target_os = "macos", target_os = "ios"))]
fn default() -> Self {
Intercept::Wrapper {
path: default_wrapper_executable(),
directory: default_wrapper_directory(),
executables: vec![], // FIXME: better default value
executables: vec![
PathBuf::from("/usr/bin/cc"),
PathBuf::from("/usr/bin/c++"),
PathBuf::from("/usr/bin/clang"),
PathBuf::from("/usr/bin/clang++"),
],
}
}

#[cfg(target_os = "windows")]
fn default() -> Self {
Intercept::Wrapper {
path: default_wrapper_executable(),
directory: default_wrapper_directory(),
executables: vec![
PathBuf::from("C:\\msys64\\mingw64\\bin\\gcc.exe"),
PathBuf::from("C:\\msys64\\mingw64\\bin\\g++.exe"),
],
}
}
}
Expand Down

0 comments on commit 8dc417a

Please sign in to comment.