diff options
author | Melody Horn <melody@boringcactus.com> | 2024-11-10 23:04:33 -0700 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2024-11-10 23:04:33 -0700 |
commit | 825ff799a2154ffb94ef21bbc14e2afe2afa2006 (patch) | |
tree | ea65adacd459f4fef69beac960aa3397ed7a66d0 /src/makefile/input.rs | |
parent | 87ce694f4d15d84e5737615b2768deaf866a796d (diff) | |
download | makers-825ff799a2154ffb94ef21bbc14e2afe2afa2006.tar.gz makers-825ff799a2154ffb94ef21bbc14e2afe2afa2006.zip |
overhaul lookup_internal
Diffstat (limited to 'src/makefile/input.rs')
-rw-r--r-- | src/makefile/input.rs | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/src/makefile/input.rs b/src/makefile/input.rs index 25d33e4..bbfdaee 100644 --- a/src/makefile/input.rs +++ b/src/makefile/input.rs @@ -24,6 +24,7 @@ use super::r#macro::ExportConfig; use super::r#macro::{Macro, Set as MacroSet}; use super::target::{StaticTargetSet, Target}; use super::token::{Token, TokenString}; +use super::LookupInternal; use super::{builtin_targets, ItemSource}; enum LineType { @@ -591,39 +592,7 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> { let mut deferred_eval_context = DeferredEvalContext::new(self); let prerequisites = self .macros - .with_lookup(&|macro_name: &str| { - let macro_pieces = if macro_name.starts_with('@') { - // The $@ shall evaluate to the full target name of the - // current target. - targets.iter() - } else { - bail!("unknown internal macro") - }; - - let macro_pieces = if macro_name.ends_with('D') { - macro_pieces - .map(|x| { - Path::new(x) - .parent() - .ok_or_else(|| eyre!("no parent")) - .map(|x| x.to_string_lossy().into()) - }) - .collect::<Result<Vec<String>, _>>()? - } else if macro_name.ends_with('F') { - macro_pieces - .map(|x| { - Path::new(x) - .file_name() - .ok_or_else(|| eyre!("no filename")) - .map(|x| x.to_string_lossy().into()) - }) - .collect::<Result<Vec<String>, _>>()? - } else { - macro_pieces.map(|&x| x.to_owned()).collect::<Vec<String>>() - }; - - Ok(macro_pieces.join(" ")) - }) + .with_lookup(LookupInternal::new_partial(&targets)) .expand( &prerequisites, #[cfg(feature = "full")] |