aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-05 15:10:02 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-05 15:10:02 -0600
commit726c4eb1f7446d678a5fca1f8ee7ca00fb8fd14d (patch)
treecdd5d885416c425faf2899c3546a2992488b0ba4
parent695f53b31955e99851c9e7c47c76f5863cea56a9 (diff)
downloadmakers-726c4eb1f7446d678a5fca1f8ee7ca00fb8fd14d.tar.gz
makers-726c4eb1f7446d678a5fca1f8ee7ca00fb8fd14d.zip
set `MAKEFILE_LIST`
-rw-r--r--src/makefile/input.rs20
1 files changed, 19 insertions, 1 deletions
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<File>> {
pub fn read_file(
args: &'a Args,
- macros: MacroSet<'parent, 'static>,
+ mut macros: MacroSet<'parent, 'static>,
path: impl AsRef<Path>,
) -> Result<Self> {
+ #[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!")?;