From 8f1a1a008aa914942aab4ef3506ebe54c5756f76 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Sat, 4 Jul 2020 16:24:51 +0200 Subject: [PATCH] fix windows pprof build --- Cargo.toml | 4 +--- src/profiler.rs | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 066d56cd..48e752e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,9 +40,7 @@ serde = "1.0" anyhow = "1.0.31" unicode-width = "0.1" -[target.'cfg(unix)'.dependencies] -pprof = { version = "0.3", features = ["flamegraph"], optional = true } -[target.'cfg(macos)'.dependencies] +[target.'cfg(not(windows))'.dependencies] pprof = { version = "0.3", features = ["flamegraph"], optional = true } [badges] diff --git a/src/profiler.rs b/src/profiler.rs index 60fbb150..cca59010 100644 --- a/src/profiler.rs +++ b/src/profiler.rs @@ -2,6 +2,7 @@ /// also we make sure to generate a flamegraph on program exit pub struct Profiler { #[cfg(feature = "pprof")] + #[cfg(not(windows))] guard: pprof::ProfilerGuard<'static>, } @@ -9,6 +10,7 @@ impl Profiler { pub fn new() -> Self { Self { #[cfg(feature = "pprof")] + #[cfg(not(windows))] guard: pprof::ProfilerGuard::new(100) .expect("profiler launch error"), } @@ -16,6 +18,7 @@ impl Profiler { fn report(&mut self) { #[cfg(feature = "pprof")] + #[cfg(not(windows))] if let Ok(report) = self.guard.report().build() { let file = std::fs::File::create("flamegraph.svg") .expect("flamegraph file err");