diff options
| -rw-r--r-- | src/makefile/input.rs | 4 | ||||
| -rw-r--r-- | src/makefile/macro.rs | 18 | ||||
| -rw-r--r-- | src/makefile/mod.rs | 2 | 
3 files changed, 20 insertions, 4 deletions
| diff --git a/src/makefile/input.rs b/src/makefile/input.rs index 2f8de49..1757222 100644 --- a/src/makefile/input.rs +++ b/src/makefile/input.rs @@ -703,6 +703,7 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {          FinishedMakefileReader {              inference_rules: self.inference_rules,              macros: self.macros.data, +            macro_exports: self.macros.exported,              targets: self.targets,              first_non_special_target: self.first_non_special_target,              failed_includes: self.failed_includes, @@ -711,7 +712,7 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {      fn extend(&mut self, new: FinishedMakefileReader) {          self.inference_rules.extend(new.inference_rules); -        self.macros.extend(new.macros); +        self.macros.extend(new.macros, new.macro_exports);          self.targets.extend(new.targets);          if self.first_non_special_target.is_none() {              self.first_non_special_target = new.first_non_special_target; @@ -723,6 +724,7 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {  pub struct FinishedMakefileReader {      pub inference_rules: Vec<InferenceRule>,      pub macros: HashMap<String, Macro>, +    pub macro_exports: ExportConfig,      pub targets: HashMap<String, Target>,      pub first_non_special_target: Option<String>,      pub failed_includes: Vec<String>, diff --git a/src/makefile/macro.rs b/src/makefile/macro.rs index 5e7ea9c..65a87d1 100644 --- a/src/makefile/macro.rs +++ b/src/makefile/macro.rs @@ -36,7 +36,7 @@ pub trait LookupInternal: for<'a> Fn(&'a str) -> Result<String> {}  impl<F: for<'a> Fn(&'a str) -> Result<String>> LookupInternal for F {}  #[cfg(feature = "full")] -#[derive(Clone)] +#[derive(Clone, Debug)]  pub enum ExportConfig {      Only(HashSet<String>),      AllBut(HashSet<String>), @@ -183,7 +183,21 @@ impl<'parent, 'lookup> Set<'parent, 'lookup> {              .or_else(|| self.parent.and_then(|p| p.get(name).cloned()))      } -    pub fn extend(&mut self, other: HashMap<String, Macro>) { +    pub fn extend(&mut self, other: HashMap<String, Macro>, other_exports: ExportConfig) { +        match (&mut self.exported, other_exports) { +            (ExportConfig::Only(se), ExportConfig::Only(oe)) => { +                se.extend(oe); +            } +            (ExportConfig::AllBut(sne), ExportConfig::AllBut(one)) => { +                sne.extend(one); +            } +            (ExportConfig::Only(se), ExportConfig::AllBut(one)) => { +                se.extend(other.keys().cloned().filter(|name| !one.contains(name))); +            } +            (ExportConfig::AllBut(sne), ExportConfig::Only(oe)) => { +                sne.extend(other.keys().cloned().filter(|name| !oe.contains(name))); +            } +        }          self.data.extend(other);      } diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs index f17ba64..cdf9d0b 100644 --- a/src/makefile/mod.rs +++ b/src/makefile/mod.rs @@ -110,7 +110,7 @@ impl<'a> Makefile<'a> {      pub fn extend(&mut self, new: FinishedMakefileReader) -> Result<()> {          self.inference_rules.extend(new.inference_rules); -        self.macros.extend(new.macros); +        self.macros.extend(new.macros, new.macro_exports);          self.targets.borrow_mut().extend(              new.targets                  .into_iter() |