diff options
Diffstat (limited to 'src/makefile/mod.rs')
-rw-r--r-- | src/makefile/mod.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs index 9255ebf..ddfac6f 100644 --- a/src/makefile/mod.rs +++ b/src/makefile/mod.rs @@ -12,7 +12,9 @@ use inference_rules::InferenceRule; use input::FinishedMakefileReader; pub use input::MakefileReader; use lookup_internal::LookupInternal; -use r#macro::{Macro, Set as MacroSet}; +pub use macro_scope::MacroScopeStack; +use r#macro::Macro; +pub use r#macro::Set as MacroSet; use target::{DynamicTargetSet, Target}; use token::TokenString; @@ -31,6 +33,7 @@ mod inference_rules; mod input; mod lookup_internal; mod r#macro; +mod macro_scope; mod pattern; mod target; mod token; @@ -51,7 +54,7 @@ pub enum ItemSource { pub struct Makefile<'a> { inference_rules: Vec<InferenceRule>, builtin_inference_rules: Vec<InferenceRule>, - pub macros: MacroSet<'static, 'static>, + pub macros: MacroSet, targets: DynamicTargetSet, pub first_non_special_target: Option<String>, args: &'a Args, @@ -157,9 +160,9 @@ impl<'a> Makefile<'a> { self.update_target(&failed_include).wrap_err_with(|| { format!("while building missing included file {}", &failed_include) })?; - let macros = self.macros.with_overlay(); + let stack = MacroScopeStack::default().with_scope(&self.macros); let file = - MakefileReader::read_file(self.args, macros, failed_include, Default::default())? + MakefileReader::read_file(self.args, stack, failed_include, Default::default())? .finish(); self.extend(file)?; } @@ -349,8 +352,9 @@ impl<'a> Makefile<'a> { } fn expand_macros(&self, text: &TokenString, target: Option<&Target>) -> Result<String> { - self.macros - .with_lookup(LookupInternal::new(target, &|name| self.get_target(name))) + MacroScopeStack::default() + .with_scope(&self.macros) + .with_scope(&LookupInternal::new(target, &|name| self.get_target(name))) .expand( text, #[cfg(feature = "full")] |