use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, gen_macros::TypedDispatcher, gen_macros::Discriminant, gen_macros::IsVariant)]
#[serde(tag = "kind", rename_all = "kebab-case")]
pub enum CrateQuirk {
ForceCfg { cfg: String },
FoldNormalIntoBuild {
#[serde(default)]
extern_crate: Option<String>,
},
SubstituteSource {
file: String,
from: String,
to: String,
},
}
pub fn registry() -> Vec<(&'static str, Vec<CrateQuirk>)> {
vec![
(
"openraft",
vec![CrateQuirk::SubstituteSource {
file: "src/metrics/wait.rs".to_string(),
from: "let got = m.membership_config.membership().voter_ids().collect();"
.to_string(),
to: "let got: std::collections::BTreeSet<_> = m.membership_config.membership().voter_ids().collect();".to_string(),
}],
),
(
"clang-sys",
vec![CrateQuirk::FoldNormalIntoBuild {
extern_crate: Some("glob".to_string()),
}],
),
(
"mime_guess",
vec![CrateQuirk::FoldNormalIntoBuild { extern_crate: None }],
),
(
"wgpu-hal",
vec![CrateQuirk::ForceCfg {
cfg: "supports_64bit_atomics".to_string(),
}],
),
(
"wgpu-core",
vec![CrateQuirk::ForceCfg {
cfg: "supports_64bit_atomics".to_string(),
}],
),
(
"wgpu",
vec![CrateQuirk::ForceCfg {
cfg: "supports_64bit_atomics".to_string(),
}],
),
(
"wgpu-types",
vec![CrateQuirk::ForceCfg {
cfg: "supports_64bit_atomics".to_string(),
}],
),
]
}
pub fn for_crate(name: &str) -> Vec<CrateQuirk> {
for (k, v) in registry() {
if k == name {
return v;
}
}
Vec::new()
}
pub fn registered_crate_names() -> Vec<&'static str> {
registry().into_iter().map(|(k, _)| k).collect()
}
gen_platform::register_dispatcher!("gen.cargo.crate-quirk", CrateQuirk);