diff options
author | Melody Horn <melody@boringcactus.com> | 2024-11-11 14:46:19 -0700 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2024-11-11 14:46:19 -0700 |
commit | fbbcf325b8bbe72f924da6a7cdb128d973ef0026 (patch) | |
tree | 783dc988b77c95fd739b30a436a496b7c0c550c2 /src/makefile/input.rs | |
parent | 5aa6e1122830611dccc2eab9b7f4a53a10056111 (diff) | |
download | makers-fbbcf325b8bbe72f924da6a7cdb128d973ef0026.tar.gz makers-fbbcf325b8bbe72f924da6a7cdb128d973ef0026.zip |
fix conditional assignment when original is inherited
Diffstat (limited to 'src/makefile/input.rs')
-rw-r--r-- | src/makefile/input.rs | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/makefile/input.rs b/src/makefile/input.rs index 40720c2..6333a66 100644 --- a/src/makefile/input.rs +++ b/src/makefile/input.rs @@ -212,7 +212,8 @@ impl<'a, 'parent> MakefileReader<'a, 'parent, BufReader<File>> { ) -> Result<Self> { let mut macros = MacroSet::new(); #[cfg(feature = "full")] - if let Some(mut old_makefile_list) = macros.pop("MAKEFILE_LIST") { + if let Some(old_makefile_list) = stack.get("MAKEFILE_LIST") { + let mut old_makefile_list = old_makefile_list.into_owned(); old_makefile_list.text.extend(TokenString::text(format!( " {}", path.as_ref().to_string_lossy() @@ -454,7 +455,7 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> { let action = line .action( self.conditional_stack.last(), - |name| self.macros.is_defined(name), + |name| self.stack.with_scope(&self.macros).is_defined(name), |t| self.expand_macros_deferred_eval(t, &mut deferred_eval_context), ) .wrap_err_with(|| { @@ -820,17 +821,16 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> { value }; - let skipped = match self.macros.get(name) { + let skipped = match self + .stack + .with_scope(&self.macros) + .get(name) + .map(|x| x.source.clone()) + { // We always let command line or MAKEFLAGS macros override macros from the file. - Some(Macro { - source: ItemSource::CommandLineOrMakeflags, - .. - }) => true, + Some(ItemSource::CommandLineOrMakeflags) => true, // We let environment variables override macros from the file only if the command-line argument to do that was given - Some(Macro { - source: ItemSource::Environment, - .. - }) => self.args.environment_overrides, + Some(ItemSource::Environment) => self.args.environment_overrides, Some(_) => skip_if_defined, None => false, }; @@ -846,8 +846,9 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> { &value ); - let value = match self.macros.pop(name) { - Some(mut old_value) if append => { + let value = match self.stack.with_scope(&self.macros).get(name) { + Some(old_value) if append => { + let mut old_value = old_value.into_owned(); #[cfg(feature = "full")] let value = if old_value.eagerly_expanded { TokenString::text(self.expand_macros(&value).wrap_err_with(|| { |