Skip to content

Commit

Permalink
Enable samply to run on Android
Browse files Browse the repository at this point in the history
Android is pretty much `linux` but needs to be enabled in the
`target_os` guards. Tested on a headless Android 9 with 5.4.
  • Loading branch information
Felix Obenhuber authored and mstange committed Nov 12, 2023
1 parent 44abaa5 commit 7758dfe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions samply/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions samply/src/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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),
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"]);
Expand Down

0 comments on commit 7758dfe

Please sign in to comment.