libservo: Make background hang monitor integration optional. (#35256)

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-02-01 15:15:39 -05:00 committed by GitHub
parent c4f4d5cc04
commit cdd6660113
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 12 additions and 5 deletions

View file

@ -23,9 +23,12 @@ libc = { workspace = true }
log = { workspace = true }
serde_json = { workspace = true }
[features]
sampler = ["unwind-sys", "mach2"]
[target.'cfg(target_os = "macos")'.dependencies]
mach2 = "0.4"
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"] }
unwind-sys = "0.1.4"
unwind-sys = { version = "0.1.4", optional = true }

View file

@ -90,13 +90,15 @@ impl BackgroundHangMonitorRegister for HangMonitorRegister {
);
#[cfg(all(
feature = "sampler",
target_os = "windows",
any(target_arch = "x86_64", target_arch = "x86")
))]
let sampler = crate::sampler_windows::WindowsSampler::new_boxed();
#[cfg(target_os = "macos")]
#[cfg(all(feature = "sampler", target_os = "macos"))]
let sampler = crate::sampler_mac::MacOsSampler::new_boxed();
#[cfg(all(
feature = "sampler",
target_os = "linux",
not(any(
target_arch = "arm",
@ -107,6 +109,7 @@ impl BackgroundHangMonitorRegister for HangMonitorRegister {
))]
let sampler = crate::sampler_linux::LinuxSampler::new_boxed();
#[cfg(any(
not(feature = "sampler"),
target_os = "android",
all(
target_os = "linux",
@ -116,7 +119,7 @@ impl BackgroundHangMonitorRegister for HangMonitorRegister {
target_env = "ohos",
target_env = "musl"
)
)
),
))]
let sampler = crate::sampler::DummySampler::new_boxed();

View file

@ -15,6 +15,7 @@ crate-type = ["rlib"]
[features]
crown = ["script/crown"]
debugmozjs = ["script/debugmozjs"]
background_hang_monitor = ["background_hang_monitor/sampler"]
jitspew = ["script/jitspew"]
js_backtrace = ["script/js_backtrace"]
layout_2013 = ["dep:layout_thread_2013"]

View file

@ -59,7 +59,7 @@ webgpu = ["libservo/webgpu"]
[dependencies]
euclid = { workspace = true }
libc = { workspace = true }
libservo = { path = "../../components/servo" }
libservo = { path = "../../components/servo", features = ["background_hang_monitor"] }
cfg-if = { workspace = true }
keyboard-types = { workspace = true }
log = { workspace = true }