aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/makefile/input.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/makefile/input.rs b/src/makefile/input.rs
index fda81d0..e8a4a42 100644
--- a/src/makefile/input.rs
+++ b/src/makefile/input.rs
@@ -90,7 +90,7 @@ fn inference_match<'a>(
pub struct MakefileReader<'a> {
inference_rules: Vec<InferenceRule>,
macros: MacroSet<'static, 'static>,
- targets: RefCell<HashMap<String, Rc<RefCell<Target>>>>,
+ targets: HashMap<String, Target>,
pub first_non_special_target: Option<String>,
args: &'a Args,
// TODO borrow warnings from Python version
@@ -106,11 +106,7 @@ impl<'a> MakefileReader<'a> {
if !args.no_builtin_rules {
inference_rules.extend(builtin_inference_rules());
macros.add_builtins();
- targets.extend(
- builtin_targets()
- .into_iter()
- .map(|t| (t.name.clone(), Rc::new(RefCell::new(t)))),
- );
+ targets.extend(builtin_targets().into_iter().map(|t| (t.name.clone(), t)));
}
macros.add_env();
@@ -128,7 +124,7 @@ impl<'a> MakefileReader<'a> {
MakefileReader {
inference_rules,
macros,
- targets: RefCell::new(targets),
+ targets,
first_non_special_target,
args,
}
@@ -337,13 +333,11 @@ impl<'a> MakefileReader<'a> {
if self.first_non_special_target.is_none() && !target.starts_with('.') {
self.first_non_special_target = Some(target.into());
}
- let mut targets = self.targets.borrow_mut();
- match targets.get_mut(target) {
+ match self.targets.get_mut(target) {
Some(old_target)
if commands.is_empty()
&& !(target == ".SUFIXES" && prerequisites.is_empty()) =>
{
- let mut old_target = old_target.borrow_mut();
let new_prerequisites = prerequisites
.iter()
.filter(|x| !old_target.prerequisites.contains(x))
@@ -358,7 +352,7 @@ impl<'a> MakefileReader<'a> {
commands: commands.clone(),
already_updated: Cell::new(false),
};
- targets.insert(target.into(), Rc::new(RefCell::new(new_target)));
+ self.targets.insert(target.into(), new_target);
}
}
}
@@ -461,7 +455,13 @@ impl<'a> From<MakefileReader<'a>> for super::Makefile<'a> {
Self {
inference_rules: reader.inference_rules,
macros: reader.macros,
- targets: reader.targets,
+ targets: RefCell::new(
+ reader
+ .targets
+ .into_iter()
+ .map(|(k, v)| (k, Rc::new(RefCell::new(v))))
+ .collect(),
+ ),
first_non_special_target: reader.first_non_special_target,
args: reader.args,
}
@@ -556,7 +556,7 @@ mod test {
MakefileReader {
inference_rules: vec![],
macros: MacroSet::new(),
- targets: RefCell::new(HashMap::new()),
+ targets: HashMap::new(),
first_non_special_target: None,
args,
}
@@ -642,7 +642,7 @@ clean:
let args = Args::empty();
let mut makefile = empty_makefile(&args);
makefile.and_read(Cursor::new(file))?;
- assert!(makefile.targets.borrow().contains_key("server"));
+ assert!(makefile.targets.contains_key("server"));
Ok(())
}
}