move the creation of the LIBRARIES IndexMap out of the generated file

- only leave the filling of the map in the generated code
This commit is contained in:
Bennet Bleßmann
2024-07-25 18:53:36 +02:00
parent 1eb6a883f6
commit 6b50ec328c
2 changed files with 14 additions and 45 deletions

View File

@@ -119,7 +119,17 @@ fn current_dir() -> PathBuf {
}
mod libraries {
include!(concat!(env!("OUT_DIR"), "/libraries.rs"));
use indexmap::IndexMap;
std::thread_local! {
static LIBRARIES: IndexMap<&'static str, &'static str> = {
let mut m = IndexMap::new();
include!(concat!(env!("OUT_DIR"), "/libraries.rs"));
m
}
}
pub(crate) fn contains(name: &str) -> bool {
LIBRARIES.with(|libs| libs.contains_key(name))
@@ -128,16 +138,6 @@ mod libraries {
pub(crate) fn get(name: &str) -> Option<&'static str> {
LIBRARIES.with(|libs| libs.get(name).copied())
}
#[cfg(test)]
std::thread_local! {
#[allow(dead_code)]
static LIBRARIES2 : IndexMap<&'static str, &'static str> = {
let mut m = IndexMap::new();
m.insert("test", "test2");
m
};
}
}
pub static BREAK_FROM_DISPATCH_LOOP_LOC: usize = 0;