aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-06 19:04:26 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-06 19:04:26 -0600
commitc94a7f83e3d9f3fb7cd023efee33a4434af5c349 (patch)
treeb82936051a603736b7c9de8eba54cedaf6d37c25 /src
parente6c04e1f4b5ebb374b3185914011b5d3b8133389 (diff)
downloadmakers-c94a7f83e3d9f3fb7cd023efee33a4434af5c349.tar.gz
makers-c94a7f83e3d9f3fb7cd023efee33a4434af5c349.zip
cut down on warning spam
Diffstat (limited to 'src')
-rw-r--r--src/makefile/macro.rs16
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),
}
}