Skip to content

Commit

Permalink
Capture Android under the 'linux' cfg
Browse files Browse the repository at this point in the history
Rust differentiates between Linux and Android at the cfg level.
Conceptually, when we say we support Linux that includes Android as
well (though we can't run tests on Android at the moment, due to
libbpf-sys not being able to compile for it).
To enshrine this constraint into our code base, adjust our 'linux' cfg
alias to include the 'android' target_os as well.

Signed-off-by: Daniel Müller <deso@posteo.net>
  • Loading branch information
d-e-s-o authored and danielocfb committed Oct 29, 2024
1 parent 4797f5a commit 707d12c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ use cfg_aliases::cfg_aliases;

fn main() {
cfg_aliases! {
linux: { target_os = "linux" },
linux: { any(target_os = "linux", target_os = "android") },
}
}
2 changes: 1 addition & 1 deletion dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ xz2 = {version = "0.1.7", optional = true}
zip = {version = "2.0.0", optional = true, default-features = false}
zstd = {version = "0.13.1", default-features = false, optional = true}

[target.'cfg(target_os = "linux")'.build-dependencies]
[target.'cfg(any(target_os = "linux", target_os = "android"))'.build-dependencies]
libbpf-sys = {version = "1.4.1", default-features = false, optional = true}
4 changes: 2 additions & 2 deletions dev/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn data_dir() -> PathBuf {
}

/// Retrieve the system's page size.
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn page_size() -> Result<usize> {
// SAFETY: `sysconf` is always safe to call.
let rc = unsafe { libc::sysconf(libc::_SC_PAGE_SIZE) };
Expand All @@ -45,7 +45,7 @@ fn page_size() -> Result<usize> {
Ok(usize::try_from(rc).unwrap())
}

#[cfg(not(target_os = "linux"))]
#[cfg(not(any(target_os = "linux", target_os = "android")))]
fn page_size() -> Result<usize> {
unimplemented!()
}
Expand Down

0 comments on commit 707d12c

Please sign in to comment.