From 6b12499077c90640b465369a273382802d1d15d3 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Thu, 6 Feb 2025 01:53:08 -0500 Subject: [PATCH] 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 * background_hang_monitor: Make nix dependency optional. Signed-off-by: Josh Matthews --------- Signed-off-by: Josh Matthews --- components/background_hang_monitor/Cargo.toml | 4 ++-- components/background_hang_monitor/lib.rs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/background_hang_monitor/Cargo.toml b/components/background_hang_monitor/Cargo.toml index e9263b29fb2..2fce92ec05d 100644 --- a/components/background_hang_monitor/Cargo.toml +++ b/components/background_hang_monitor/Cargo.toml @@ -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 } diff --git a/components/background_hang_monitor/lib.rs b/components/background_hang_monitor/lib.rs index 0ea56ccbc96..8f594a7fc02 100644 --- a/components/background_hang_monitor/lib.rs +++ b/components/background_hang_monitor/lib.rs @@ -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::*;