From 7758dfef466b570aa31bf009e0899cacbbafda48 Mon Sep 17 00:00:00 2001 From: Felix Obenhuber Date: Tue, 7 Nov 2023 12:36:44 +0100 Subject: [PATCH] Enable samply to run on Android Android is pretty much `linux` but needs to be enabled in the `target_os` guards. Tested on a headless Android 9 with 5.4. --- samply/Cargo.toml | 4 ++-- samply/src/main.rs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/samply/Cargo.toml b/samply/Cargo.toml index 71ce557e..66be8cb4 100644 --- a/samply/Cargo.toml +++ b/samply/Cargo.toml @@ -43,7 +43,7 @@ once_cell = "1.17" fxhash = "0.2.1" mio = { version = "0.8.6", features = ["os-ext", "os-poll"] } -[target.'cfg(any(target_os = "macos", target_os = "linux"))'.dependencies] +[target.'cfg(any(target_os = "android", target_os = "macos", target_os = "linux"))'.dependencies] libc = "0.2.71" crossbeam-channel = "0.5.4" @@ -56,7 +56,7 @@ lazy_static = "1.4.0" flate2 = "1.0.23" sysctl = "0.5.4" -[target.'cfg(target_os = "linux")'.dependencies] +[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies] parking_lot = "0.12.1" num_cpus = "1.13.1" diff --git a/samply/src/main.rs b/samply/src/main.rs index 939b7c02..f03c71b3 100644 --- a/samply/src/main.rs +++ b/samply/src/main.rs @@ -1,7 +1,7 @@ #[cfg(target_os = "macos")] mod mac; -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "android", target_os = "linux"))] mod linux; mod import; @@ -22,7 +22,7 @@ use std::time::Duration; #[cfg(target_os = "macos")] pub use mac::{kernel_error, thread_act, thread_info}; -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "android", target_os = "linux"))] use linux::profiler; #[cfg(target_os = "macos")] use mac::profiler; @@ -64,7 +64,7 @@ enum Action { /// Load a profile from a file and display it. Load(LoadArgs), - #[cfg(any(target_os = "macos", target_os = "linux"))] + #[cfg(any(target_os = "android", target_os = "macos", target_os = "linux"))] /// Record a profile and display it. Record(RecordArgs), } @@ -176,7 +176,7 @@ fn main() { start_server_main(filename, load_args.server_args.server_props()); } - #[cfg(any(target_os = "macos", target_os = "linux"))] + #[cfg(any(target_os = "android", target_os = "macos", target_os = "linux"))] Action::Record(record_args) => { let server_props = if record_args.save_only { None @@ -308,7 +308,7 @@ mod test { Opt::command().debug_assert(); } - #[cfg(any(target_os = "macos", target_os = "linux"))] + #[cfg(any(target_os = "android", target_os = "macos", target_os = "linux"))] #[test] fn verify_cli_record() { let opt = Opt::parse_from(["samply", "record", "rustup", "show"]);