tiger-lib 1.18.0

Library used by the tools ck3-tiger, vic3-tiger, and imperator-tiger. This library holds the bulk of the code for them. It can be built either for ck3-tiger with the feature ck3, or for vic3-tiger with the feature vic3, or for imperator-tiger with the feature imperator, but not both at the same time.
Documentation
use serde::Deserialize;
use std::{fs, path::PathBuf, sync::LazyLock};

static CONFIG_PATH: &str = "benches/vic3.toml";

// Sample Config File:
// vanilla_dir = "..."
// mod_dir = "..."
// mod_paths = ["...", "..."]

#[derive(Deserialize)]
struct Config {
    vanilla_dir: String,
    mod_dir: Option<String>,
    mod_paths: Vec<String>,
}

static CONFIG: LazyLock<Config> = LazyLock::new(|| {
    let content = fs::read_to_string(CONFIG_PATH).unwrap();
    toml::from_str(&content).unwrap()
});
static MOD_PATHS: LazyLock<Vec<PathBuf>> = LazyLock::new(|| {
    let mut mod_paths = CONFIG.mod_paths.iter().map(PathBuf::from).collect::<Vec<_>>();
    if let Some(mod_dir) = &CONFIG.mod_dir {
        let iter =
            fs::read_dir(mod_dir).unwrap().filter_map(|entry| entry.ok()).filter_map(|entry| {
                entry.path().join(".metadata/metadata.json").is_file().then(|| entry.path())
            });
        mod_paths.extend(iter);
    }
    mod_paths
});

pub fn bench_mods<'a>() -> impl Iterator<Item = (&'a str, &'a PathBuf)> {
    MOD_PATHS.iter().map(move |mod_path| (CONFIG.vanilla_dir.as_str(), mod_path))
}