aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2024-11-11 00:07:33 -0700
committerMelody Horn <melody@boringcactus.com>2024-11-11 00:07:33 -0700
commitec2c18171cd316a8b1f69baf92f67980820dfc9a (patch)
tree007add1cd59aec07098134b018efededee463d97 /src/main.rs
parent825ff799a2154ffb94ef21bbc14e2afe2afa2006 (diff)
downloadmakers-ec2c18171cd316a8b1f69baf92f67980820dfc9a.tar.gz
makers-ec2c18171cd316a8b1f69baf92f67980820dfc9a.zip
overhaul macro inheritance
i was really proud of the lifetimes i had going on in the previous code. i should not have been.
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)?;