From 726c4eb1f7446d678a5fca1f8ee7ca00fb8fd14d Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Mon, 5 Apr 2021 15:10:02 -0600 Subject: set `MAKEFILE_LIST` --- src/makefile/input.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/makefile/input.rs b/src/makefile/input.rs index d6cffdf..d90378d 100644 --- a/src/makefile/input.rs +++ b/src/makefile/input.rs @@ -158,9 +158,27 @@ pub struct MakefileReader<'a, 'parent, R: BufRead> { impl<'a, 'parent> MakefileReader<'a, 'parent, BufReader> { pub fn read_file( args: &'a Args, - macros: MacroSet<'parent, 'static>, + mut macros: MacroSet<'parent, 'static>, path: impl AsRef, ) -> Result { + #[cfg(feature = "full")] + if let Some((_, mut old_makefile_list)) = macros.pop("MAKEFILE_LIST") { + old_makefile_list.extend(TokenString::text(format!( + " {}", + path.as_ref().to_string_lossy() + ))); + macros.set( + "MAKEFILE_LIST".to_owned(), + MacroSource::Builtin, + old_makefile_list, + ); + } else { + macros.set( + "MAKEFILE_LIST".to_owned(), + MacroSource::Builtin, + TokenString::text(path.as_ref().to_string_lossy()), + ); + } let file = File::open(path); // TODO handle errors let file = file.context("couldn't open makefile!")?; -- cgit v1.2.3