From 6dbb6548990841e7aeb991b76a58e14d237e79d0 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Tue, 6 Apr 2021 18:29:50 -0600 Subject: fix exports oops --- src/makefile/input.rs | 4 +++- src/makefile/macro.rs | 18 ++++++++++++++++-- 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, pub macros: HashMap, + pub macro_exports: ExportConfig, pub targets: HashMap, pub first_non_special_target: Option, pub failed_includes: Vec, 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 {} impl Fn(&'a str) -> Result> LookupInternal for F {} #[cfg(feature = "full")] -#[derive(Clone)] +#[derive(Clone, Debug)] pub enum ExportConfig { Only(HashSet), AllBut(HashSet), @@ -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) { + pub fn extend(&mut self, other: HashMap, 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() -- cgit v1.2.3