aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs
index d4c0cdc..0b3e9f7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -32,7 +32,7 @@ mod args;
mod makefile;
use args::Args;
-use makefile::{Makefile, MakefileReader};
+use makefile::{MacroScopeStack, MacroSet, Makefile, MakefileReader};
const DEFAULT_PATHS: &[&str] = &[
#[cfg(feature = "full")]
@@ -66,14 +66,16 @@ fn main() -> Result<()> {
let mut makefile = Makefile::new(&args);
let paths = Default::default();
for filename in &args.makefile {
- let macros = makefile.macros.with_overlay();
+ let stack = MacroScopeStack::default().with_scope(&makefile.macros);
if filename == &PathBuf::from("-") {
- let file = MakefileReader::read(&args, macros, stdin().lock(), "-", Rc::clone(&paths))?
- .finish();
+ let macros = MacroSet::new();
+ let file =
+ MakefileReader::read(&args, stack, macros, stdin().lock(), "-", Rc::clone(&paths))?
+ .finish();
makefile.extend(file)?;
} else {
let file =
- MakefileReader::read_file(&args, macros, filename, Rc::clone(&paths))?.finish();
+ MakefileReader::read_file(&args, stack, filename, Rc::clone(&paths))?.finish();
makefile.extend(file)?;
};
}
@@ -91,9 +93,8 @@ fn main() -> Result<()> {
for outdated in makefiles_outdated {
eprintln!("makefile {} out of date, rebuilding", outdated);
makefile.update_target(&outdated)?;
- let macros = makefile.macros.with_overlay();
- let file =
- MakefileReader::read_file(&args, macros, &outdated, Default::default())?.finish();
+ let stack = MacroScopeStack::default().with_scope(&makefile.macros);
+ let file = MakefileReader::read_file(&args, stack, &outdated, Default::default())?.finish();
// TODO forget the stale data
// TODO reread all the things, not just this one
makefile.extend(file)?;