aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/makefile/mod.rs')
-rw-r--r--src/makefile/mod.rs34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs
index 5c38ab3..d7cc25e 100644
--- a/src/makefile/mod.rs
+++ b/src/makefile/mod.rs
@@ -41,7 +41,7 @@ pub struct Makefile<'a> {
inference_rules: Vec<InferenceRule>,
builtin_inference_rules: Vec<InferenceRule>,
pub macros: MacroSet<'static, 'static>,
- targets: RefCell<DynamicTargetSet>,
+ targets: DynamicTargetSet,
pub first_non_special_target: Option<String>,
args: &'a Args,
// TODO borrow warnings from Python version
@@ -51,7 +51,7 @@ impl<'a> Makefile<'a> {
pub fn new(args: &'a Args) -> Self {
let mut inference_rules = vec![];
let mut macros = MacroSet::new();
- let mut targets = DynamicTargetSet::default();
+ let targets = DynamicTargetSet::default();
let first_non_special_target = None;
macros.set(
@@ -120,7 +120,7 @@ impl<'a> Makefile<'a> {
inference_rules: vec![],
builtin_inference_rules: inference_rules,
macros,
- targets: RefCell::new(targets),
+ targets,
first_non_special_target,
args,
}
@@ -134,7 +134,7 @@ impl<'a> Makefile<'a> {
new.macro_exports,
);
for (_, target) in new.targets {
- self.targets.borrow_mut().put(target);
+ self.targets.put(target);
}
if self.first_non_special_target.is_none() {
self.first_non_special_target = new.first_non_special_target;
@@ -152,8 +152,7 @@ impl<'a> Makefile<'a> {
}
fn special_target_has_prereq(&self, target: &str, name: &str) -> bool {
- let targets = self.targets.borrow();
- match targets.get(target) {
+ match self.targets.get(target) {
Some(target) => {
let target = target.borrow();
target.prerequisites.is_empty() || target.prerequisites.iter().any(|e| e == name)
@@ -211,7 +210,7 @@ impl<'a> Makefile<'a> {
// we can't build this based on itself! fuck outta here
return None;
}
- if self.targets.borrow().has(&prereq_path_name) {
+ if self.targets.has(&prereq_path_name) {
return Some(prereq_path_name);
}
let prereq_path = PathBuf::from(&prereq_path_name);
@@ -234,7 +233,7 @@ impl<'a> Makefile<'a> {
self.infer_target(&prereq_path_name, banned_rules, banned_names)
.ok()
.and_then(|_| {
- if self.targets.borrow().has(&prereq_path_name) {
+ if self.targets.has(&prereq_path_name) {
Some(prereq_path_name)
} else {
None
@@ -259,7 +258,7 @@ impl<'a> Makefile<'a> {
}
if let Some(new_target) = new_target {
- self.targets.borrow_mut().put(new_target);
+ self.targets.put(new_target);
}
Ok(())
@@ -271,22 +270,20 @@ impl<'a> Makefile<'a> {
let exists_but_infer_anyway = if follow_gnu {
self.targets
- .borrow()
.get(name)
.map_or(false, |target| target.borrow().commands.is_empty())
} else {
false
};
- if !self.targets.borrow().has(name) || exists_but_infer_anyway {
+ if !self.targets.has(name) || exists_but_infer_anyway {
log::trace!("trying to infer for {}", name);
self.infer_target(name, vec![], vec![])?;
}
let mut new_target = None;
- let targets = self.targets.borrow();
- if !targets.has(name) {
+ if !self.targets.has(name) {
// well, inference didn't work. is there a default?
- if let Some(default) = targets.get(".DEFAULT") {
+ if let Some(default) = self.targets.get(".DEFAULT") {
let commands = default.borrow().commands.clone();
new_target = Some(Target {
name: name.into(),
@@ -309,13 +306,12 @@ impl<'a> Makefile<'a> {
}
}
- drop(targets);
if let Some(new_target) = new_target {
- self.targets.borrow_mut().put(new_target);
+ self.targets.put(new_target);
}
- let targets = self.targets.borrow();
- Ok(targets
+ Ok(self
+ .targets
.get(name)
.ok_or_else(|| eyre!("Target {:?} not found!", name))?)
}
@@ -416,7 +412,7 @@ impl fmt::Display for Makefile<'_> {
writeln!(f)?;
header(f, "Targets")?;
- writeln!(f, "{}", &self.targets.borrow())?;
+ writeln!(f, "{}", &self.targets)?;
Ok(())
}