Skip to content

Commit

Permalink
Support build for target_os android
Browse files Browse the repository at this point in the history
The target_os `android` is quite similar to `linux` but must be
mentioned in the guards explicitly. Tested for target
`aarch64-linux-android`.
  • Loading branch information
flxoacn committed Apr 2, 2024
1 parent 6ef2d56 commit f647d6a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
* Remove unnecessary logging synchronisation #381 - @cyqsimon
* Apply suggestions from new clippy lint clippy::assigning_clones #382 - @cyqsimon
* Fix IPv6 socket detect logic #383 - @cyqsimon
* Support build for `target_os`` `android` #384 - @flxo

## Added
* CI: include generated assets in release archive #359 - @cyqsimon
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ trust-dns-resolver = "0.23.2"
unicode-width = "0.1.11"
strum = { version = "0.26.2", features = ["derive"] }

[target.'cfg(target_os = "linux")'.dependencies]
[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
procfs = "0.16.0"

[target.'cfg(any(target_os = "macos", target_os = "freebsd"))'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/os/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
mod linux;

#[cfg(any(target_os = "macos", target_os = "freebsd"))]
Expand Down
4 changes: 2 additions & 2 deletions src/os/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tokio::runtime::Runtime;

use crate::{network::dns, os::errors::GetInterfaceError, OsInputOutput};

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
use crate::os::linux::get_open_sockets;
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
use crate::os::lsof::get_open_sockets;
Expand Down Expand Up @@ -220,7 +220,7 @@ fn eperm_message() -> &'static str {
}

#[inline]
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
fn eperm_message() -> &'static str {
r#"
Insufficient permissions to listen on network interface(s). You can work around
Expand Down

0 comments on commit f647d6a

Please sign in to comment.