From 3ad4b05a97642810b3975c03d6adff14b331146c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bennet=20Ble=C3=9Fmann?= Date: Thu, 25 Jul 2024 23:09:17 +0200 Subject: [PATCH] add a features for gating things we can use once 1.80 is msrv --- Cargo.toml | 1 + src/machine/mod.rs | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 67c3e60d..180015ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ hostname = ["dep:hostname"] tls = ["dep:native-tls"] http = ["dep:warp", "dep:reqwest"] crypto-full = [] +"rust-version-1.80" = [] [build-dependencies] indexmap = "1.0.2" diff --git a/src/machine/mod.rs b/src/machine/mod.rs index 1726ae5b..9110ae9c 100644 --- a/src/machine/mod.rs +++ b/src/machine/mod.rs @@ -118,6 +118,7 @@ fn current_dir() -> PathBuf { } } +#[cfg(not(feature = "rust-version-1.80"))] mod libraries { use indexmap::IndexMap; use std::sync::OnceLock; @@ -142,6 +143,28 @@ mod libraries { } } +#[cfg(feature = "rust-version-1.80")] +mod libraries { + use indexmap::IndexMap; + use std::sync::LazyLock; + + static LIBRARIES: LazyLock> = OnceLock::new(|| { + let mut m = IndexMap::new(); + + include!(concat!(env!("OUT_DIR"), "/libraries.rs")); + + m + }); + + pub(crate) fn contains(name: &str) -> bool { + LIBRARIES.contains_key(name) + } + + pub(crate) fn get(name: &str) -> Option<&'static str> { + LIBRARIES.get(name).copied() + } +} + pub static BREAK_FROM_DISPATCH_LOOP_LOC: usize = 0; pub static INSTALL_VERIFY_ATTR_INTERRUPT: usize = 1; pub static VERIFY_ATTR_INTERRUPT_LOC: usize = 2; -- 2.54.0