aboutsummaryrefslogtreecommitdiff
path: root/src/makefile
diff options
context:
space:
mode:
authorzseri <zseri.devel@ytrizja.de>2021-03-27 08:33:38 +0100
committerzseri <zseri.devel@ytrizja.de>2021-03-27 08:33:38 +0100
commit50ca0a1c9b186200094c29c1bbc4441b7afb2984 (patch)
tree18237f9b165fb8367f0d9d9bd64a1aa3b3692e76 /src/makefile
parent0ceb7e2fae841be5662b0bf71a33e9d9083ec11d (diff)
downloadmakers-50ca0a1c9b186200094c29c1bbc4441b7afb2984.tar.gz
makers-50ca0a1c9b186200094c29c1bbc4441b7afb2984.zip
other simple stuff
Diffstat (limited to 'src/makefile')
-rw-r--r--src/makefile/mod.rs21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs
index 735c8aa..bf4006a 100644
--- a/src/makefile/mod.rs
+++ b/src/makefile/mod.rs
@@ -617,9 +617,7 @@ impl<'a> Makefile<'a> {
if !targets.contains_key(name) && new_target.is_none() {
// well, inference didn't work. is there a default?
if let Some(default) = targets.get(".DEFAULT") {
- let default = default.borrow();
- let commands = default.commands.clone();
- drop(default);
+ let commands = default.borrow().commands.clone();
new_target = Some(Target {
name: name.into(),
prerequisites: vec![],
@@ -641,8 +639,9 @@ impl<'a> Makefile<'a> {
drop(targets);
if let Some(new_target) = new_target {
- let mut targets = self.targets.borrow_mut();
- targets.insert(new_target.name.clone(), Rc::new(RefCell::new(new_target)));
+ self.targets
+ .borrow_mut()
+ .insert(new_target.name.clone(), Rc::new(RefCell::new(new_target)));
}
let targets = self.targets.borrow();
@@ -650,9 +649,7 @@ impl<'a> Makefile<'a> {
}
pub fn update_target(&self, name: &str) {
- let target = self.get_target(name);
- let target = target.borrow();
- target.update(self);
+ self.get_target(name).borrow().update(self);
}
fn expand_macros(&self, text: &TokenString, target: Option<&Target>) -> String {
@@ -729,10 +726,10 @@ impl<'a> Makefile<'a> {
macro_pieces.join(" ")
} else {
- match self.macros.get(name) {
- Some((_, macro_value)) => self.expand_macros(&macro_value, target),
- None => String::new(),
- }
+ self.macros
+ .get(name)
+ .map(|(_, macro_value)| self.expand_macros(&macro_value, target))
+ .unwrap_or_else(String::new)
};
let macro_value = match replacement {
Some((subst1, subst2)) => {