diff options
Diffstat (limited to 'src/makefile/target.rs')
-rw-r--r-- | src/makefile/target.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/makefile/target.rs b/src/makefile/target.rs index c3431e4..9f81802 100644 --- a/src/makefile/target.rs +++ b/src/makefile/target.rs @@ -8,9 +8,7 @@ use std::time::SystemTime; use eyre::{Result, WrapErr}; -use crate::makefile::command_line::CommandLine; - -use super::Makefile; +use super::{CommandLine, MacroSet, Makefile}; #[derive(PartialEq, Eq, Clone, Debug)] pub struct Target { @@ -19,10 +17,11 @@ pub struct Target { pub commands: Vec<CommandLine>, pub stem: Option<String>, pub already_updated: Cell<bool>, + pub macros: MacroSet, } impl Target { - pub fn extend(&mut self, other: Target) { + pub fn extend(&mut self, other: Self) { assert_eq!(&self.name, &other.name); match (self.commands.is_empty(), other.commands.is_empty()) { (false, false) => { @@ -43,6 +42,7 @@ impl Target { self.stem = self.stem.take().or(other.stem); let already_updated = self.already_updated.get() || other.already_updated.get(); self.already_updated.set(already_updated); + self.macros.extend(other.macros); } } } @@ -152,11 +152,15 @@ impl StaticTargetSet { self.data.insert(target.name.clone(), target); } } + + pub fn has(&self, name: &str) -> bool { + self.data.contains_key(name) + } } -impl Into<HashMap<String, Target>> for StaticTargetSet { - fn into(self) -> HashMap<String, Target> { - self.data +impl From<StaticTargetSet> for HashMap<String, Target> { + fn from(value: StaticTargetSet) -> Self { + value.data } } @@ -168,7 +172,7 @@ pub struct DynamicTargetSet { impl DynamicTargetSet { pub fn get(&self, name: &str) -> Option<Rc<RefCell<Target>>> { - self.data.borrow().get(name).map(|x| Rc::clone(x)) + self.data.borrow().get(name).map(Rc::clone) } pub fn put(&self, target: Target) { |