Only compile platform samplers when cargo feature enabled (#35312)

* background_hang_monitor: Only compile platform samplers when cargo feature enabled.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* background_hang_monitor: Make nix dependency optional.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-02-06 01:53:08 -05:00 committed by GitHub
parent 0de6d1bc3a
commit 6b12499077
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View file

@ -24,11 +24,11 @@ log = { workspace = true }
serde_json = { workspace = true }
[features]
sampler = ["unwind-sys", "mach2"]
sampler = ["unwind-sys", "mach2", "nix"]
[target.'cfg(target_os = "macos")'.dependencies]
mach2 = { version = "0.4", optional = true }
[target.'cfg(all(target_os = "linux", not(any(target_arch = "arm", target_arch = "aarch64", target_env = "ohos", target_env = "musl"))))'.dependencies]
nix = { workspace = true, features = ["signal"] }
nix = { workspace = true, features = ["signal"], optional = true }
unwind-sys = { version = "0.1.4", optional = true }

View file

@ -7,6 +7,7 @@
pub mod background_hang_monitor;
mod sampler;
#[cfg(all(
feature = "sampler",
target_os = "linux",
not(any(
target_arch = "arm",
@ -16,9 +17,9 @@ mod sampler;
))
))]
mod sampler_linux;
#[cfg(target_os = "macos")]
#[cfg(all(feature = "sampler", target_os = "macos"))]
mod sampler_mac;
#[cfg(target_os = "windows")]
#[cfg(all(feature = "sampler", target_os = "windows"))]
mod sampler_windows;
pub use self::background_hang_monitor::*;