diff options
author | Melody Horn <melody@boringcactus.com> | 2021-04-14 19:26:39 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-04-14 19:26:39 -0600 |
commit | d64e044ae288afdae80bc5e479d902d7f98cb6ea (patch) | |
tree | fe090628abcb0621bda3045a1d097bd83efd54ff | |
parent | 904367736833aace24cdd778da64aeb363b52338 (diff) | |
download | makers-d64e044ae288afdae80bc5e479d902d7f98cb6ea.tar.gz makers-d64e044ae288afdae80bc5e479d902d7f98cb6ea.zip |
never try twice to infer a target
-rw-r--r-- | src/makefile/mod.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs index d7cc25e..7cc16c5 100644 --- a/src/makefile/mod.rs +++ b/src/makefile/mod.rs @@ -1,4 +1,5 @@ use std::cell::{Cell, RefCell}; +use std::collections::HashSet; use std::env; use std::fmt; use std::path::{Path, PathBuf}; @@ -44,6 +45,7 @@ pub struct Makefile<'a> { targets: DynamicTargetSet, pub first_non_special_target: Option<String>, args: &'a Args, + already_inferred: RefCell<HashSet<String>>, // TODO borrow warnings from Python version } @@ -123,6 +125,7 @@ impl<'a> Makefile<'a> { targets, first_non_special_target, args, + already_inferred: Default::default(), } } @@ -170,6 +173,10 @@ impl<'a> Makefile<'a> { if banned_names.contains(&name) { bail!("no infinite recursion allowed"); } + if self.already_inferred.borrow().contains(name) { + return Ok(()); + } + self.already_inferred.borrow_mut().insert(name.to_owned()); log::trace!("inferring {}, stack = {:?}", name, banned_names); let mut new_target = None; @@ -519,6 +526,7 @@ mod test { targets: Default::default(), first_non_special_target: None, args: &args, + already_inferred: Default::default(), }; let target = file.get_target("this-is-a-test-case")?; |