diff options
Diffstat (limited to 'src/makefile/macro.rs')
-rw-r--r-- | src/makefile/macro.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/makefile/macro.rs b/src/makefile/macro.rs index c8a9542..6a456af 100644 --- a/src/makefile/macro.rs +++ b/src/makefile/macro.rs @@ -1,11 +1,8 @@ -#[cfg(feature = "full")] use std::cell::RefCell; use std::collections::HashMap; -#[cfg(feature = "full")] use std::collections::HashSet; use std::env; use std::fmt; -#[cfg(feature = "full")] use std::rc::Rc; use eyre::{bail, Result, WrapErr}; @@ -102,6 +99,7 @@ pub struct Set<'parent, 'lookup> { pub to_eval: Rc<RefCell<Vec<String>>>, #[cfg(feature = "full")] pub exported: ExportConfig, + warnings: Rc<RefCell<HashSet<String>>>, } impl<'parent, 'lookup> Set<'parent, 'lookup> { @@ -114,6 +112,7 @@ impl<'parent, 'lookup> Set<'parent, 'lookup> { to_eval: Rc::new(RefCell::new(Vec::new())), #[cfg(feature = "full")] exported: ExportConfig::only(), + warnings: Default::default(), } } @@ -206,6 +205,13 @@ impl<'parent, 'lookup> Set<'parent, 'lookup> { self.data.extend(other); } + fn warn(&self, text: String) { + if !self.warnings.borrow().contains(&text) { + log::warn!("{}", &text); + self.warnings.borrow_mut().insert(text); + } + } + pub fn expand(&self, text: &TokenString) -> Result<String> { let mut result = String::new(); for token in text.tokens() { @@ -224,7 +230,7 @@ impl<'parent, 'lookup> Set<'parent, 'lookup> { } else { self.get(&name).map_or_else( || { - log::warn!("undefined macro {}", name); + self.warn(format!("undefined macro {}", name)); Ok(String::new()) }, |x| self.expand(&x.text), @@ -294,6 +300,7 @@ impl<'parent, 'lookup> Set<'parent, 'lookup> { to_eval: Rc::clone(&self.to_eval), #[cfg(feature = "full")] exported: self.exported.same_type(), + warnings: Rc::clone(&self.warnings), } } @@ -306,6 +313,7 @@ impl<'parent, 'lookup> Set<'parent, 'lookup> { to_eval: Rc::clone(&self.to_eval), #[cfg(feature = "full")] exported: self.exported.same_type(), + warnings: Rc::clone(&self.warnings), } } |