From 5a101a96ada9ddbd4be54c46cd7d0125825c2283 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Tue, 6 Apr 2021 14:11:43 -0600 Subject: eagerly expand when appending to eagerly-expanded macros --- src/makefile/mod.rs | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'src/makefile/mod.rs') diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs index 308d25d..aab5054 100644 --- a/src/makefile/mod.rs +++ b/src/makefile/mod.rs @@ -25,7 +25,7 @@ use command_line::CommandLine; use inference_rules::InferenceRule; use input::FinishedMakefileReader; pub use input::MakefileReader; -use r#macro::{Set as MacroSet, Source as MacroSource}; +use r#macro::{Macro, Set as MacroSet, Source as MacroSource}; use target::Target; use token::TokenString; @@ -62,8 +62,12 @@ impl<'a> Makefile<'a> { if let [name, value] = *r#macro.splitn(2, '=').collect::>() { macros.set( name.into(), - MacroSource::CommandLineOrMakeflags, - TokenString::text(value), + Macro { + source: MacroSource::CommandLineOrMakeflags, + text: TokenString::text(value), + #[cfg(feature = "full")] + eagerly_expanded: false, + }, ); } } @@ -73,15 +77,23 @@ impl<'a> Makefile<'a> { let make_cmd_goals = args.targets().collect::>(); macros.set( "MAKECMDGOALS".to_owned(), - MacroSource::Builtin, - TokenString::text(make_cmd_goals.join(" ")), + Macro { + source: MacroSource::Builtin, + text: TokenString::text(make_cmd_goals.join(" ")), + #[cfg(feature = "full")] + eagerly_expanded: false, + }, ); if let Ok(curdir) = env::current_dir() { macros.set( "CURDIR".to_owned(), - MacroSource::Builtin, - TokenString::text(curdir.to_string_lossy()), + Macro { + source: MacroSource::Builtin, + text: TokenString::text(curdir.to_string_lossy()), + #[cfg(feature = "full")] + eagerly_expanded: false, + }, ); } } @@ -135,8 +147,8 @@ impl<'a> Makefile<'a> { let follow_gnu = cfg!(feature = "full"); let vpath_options = match self.macros.get("VPATH") { - Some((_, vpath)) if follow_gnu => { - let vpath = self.expand_macros(vpath, None)?; + Some(Macro { text, .. }) if follow_gnu => { + let vpath = self.expand_macros(text, None)?; env::split_paths(&vpath).collect() } _ => vec![], -- cgit v1.2.3