diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/whatsys/src/lib.rs | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/whatsys/src/lib.rs')
-rw-r--r-- | third_party/rust/whatsys/src/lib.rs | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/third_party/rust/whatsys/src/lib.rs b/third_party/rust/whatsys/src/lib.rs new file mode 100644 index 0000000000..1e071343b7 --- /dev/null +++ b/third_party/rust/whatsys/src/lib.rs @@ -0,0 +1,70 @@ +//! What kernel version is running? +//! +//! # Example +//! +//! ``` +//! let kernel = whatsys::kernel_version(); // E.g. Some("20.3.0") +//! ``` +//! +//! # Supported operating systems +//! +//! We support the following operating systems: +//! +//! * Windows +//! * macOS +//! * Linux +//! * Android +//! +//! # License +//! +//! MIT. Copyright (c) 2021-2022 Jan-Erik Rediger +//! +//! Based on: +//! +//! * [sys-info](https://crates.io/crates/sys-info), [Repository](https://github.com/FillZpp/sys-info-rs), [MIT LICENSE][sys-info-mit] +//! * [sysinfo](https://crates.io/crates/sysinfo), [Repository](https://github.com/GuillaumeGomez/sysinfo), [MIT LICENSE][sysinfo-mit] +//! +//! [sys-info-mit]: https://github.com/FillZpp/sys-info-rs/blob/master/LICENSE +//! [sysinfo-mit]: https://github.com/GuillaumeGomez/sysinfo/blob/master/LICENSE + +#![deny(missing_docs)] +#![deny(rustdoc::broken_intra_doc_links)] + +cfg_if::cfg_if! { + if #[cfg(target_os = "macos")] { + mod apple; + use apple as system; + + } else if #[cfg(any(target_os = "linux", target_os = "android"))] { + mod linux; + use linux as system; + } else if #[cfg(windows)] { + mod windows; + use windows as system; + } else { + mod fallback; + use fallback as system; + } +} + +pub use system::kernel_version; + +#[cfg(target_os = "windows")] +pub use system::windows_build_number; + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn gets_a_version() { + assert!(kernel_version().is_some()); + } + + #[cfg(target_os = "windows")] + #[test] + fn test_windows_build_number() { + let build_number = windows::windows_build_number(); + assert!(build_number.is_some()); + } +} |