diff options
author | Melody Horn <melody@boringcactus.com> | 2024-11-15 20:49:47 -0700 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2024-11-15 20:49:47 -0700 |
commit | bdac807c274d7b87cec2502f7981c16b7fceec7b (patch) | |
tree | 8112c8dc70f6fa56635c6e501e7da9d64f483c70 /src/makefile/input.rs | |
parent | 3ff7fec59481cda6d01e57bdd341c9a0efbcc2a0 (diff) | |
download | makers-bdac807c274d7b87cec2502f7981c16b7fceec7b.tar.gz makers-bdac807c274d7b87cec2502f7981c16b7fceec7b.zip |
implement secondary expansion
Diffstat (limited to 'src/makefile/input.rs')
-rw-r--r-- | src/makefile/input.rs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/makefile/input.rs b/src/makefile/input.rs index 2879b63..74742f9 100644 --- a/src/makefile/input.rs +++ b/src/makefile/input.rs @@ -614,6 +614,22 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> { #[cfg(feature = "full")] Some(&mut deferred_eval_context), )?; + // https://www.gnu.org/software/make/manual/html_node/Secondary-Expansion.html + // this is supposed to be deferred but maybe i can get away with this + // TODO move this to run at runtime + #[cfg(feature = "full")] + let prerequisites = if self.targets.has(".SECONDEXPANSION") { + self.stack + .with_scope(&self.macros) + .with_scope(&LookupInternal::new_partial(&targets)) + .expand( + &prerequisites.parse()?, + #[cfg(feature = "full")] + Some(&mut deferred_eval_context), + )? + } else { + prerequisites + }; #[cfg(feature = "full")] for child in deferred_eval_context { self.extend(child); @@ -693,10 +709,7 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> { } } } else { - log::debug!( - "pattern-based inference rule defined: {:?}", - &new_rule, - ); + log::debug!("pattern-based inference rule defined: {:?}", &new_rule,); self.inference_rules.put(new_rule); } return Ok(()); |