Support build.rs cargo:rustc-cfg

This commit is contained in:
robojumper 2020-05-04 13:29:09 +02:00
parent 6a48a94d47
commit 2980ba1fde
4 changed files with 158 additions and 3 deletions

View file

@ -53,4 +53,13 @@ impl CfgOptions {
pub fn insert_features(&mut self, iter: impl IntoIterator<Item = SmolStr>) {
iter.into_iter().for_each(|feat| self.insert_key_value("feature".into(), feat));
}
/// Shortcut to set cfgs
pub fn insert_cfgs(&mut self, iter: impl IntoIterator<Item = SmolStr>) {
iter.into_iter().for_each(|cfg| match cfg.find('=') {
Some(split) => self
.insert_key_value(cfg[0..split].into(), cfg[split + 1..].trim_matches('"').into()),
None => self.insert_atom(cfg),
});
}
}