From a17224fa6300452800c7162e9eb8948025a5dbb1 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Wed, 14 Apr 2021 14:28:59 -0600 Subject: always recurse when in dry-run etc mode --- src/makefile/command_line.rs | 9 +++++++-- src/makefile/token.rs | 9 +++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src/makefile') diff --git a/src/makefile/command_line.rs b/src/makefile/command_line.rs index 1b4b4b4..f9cd876 100644 --- a/src/makefile/command_line.rs +++ b/src/makefile/command_line.rs @@ -80,6 +80,10 @@ impl CommandLine { } pub fn execute(&self, file: &Makefile, target: &Target) -> eyre::Result<()> { + let is_recursive = self.execution_line.tokens().any(|x| match x { + Token::MacroExpansion { name, .. } => name == "MAKE", + _ => false, + }); let execution_line = file.expand_macros(&self.execution_line, Some(target))?; let mut self_ignore_errors = self.ignore_errors; let mut self_silent = self.silent; @@ -110,8 +114,9 @@ impl CommandLine { println!("{}", execution_line); } - let should_execute = - self_always_execute || !(file.args.dry_run || file.args.question || file.args.touch); + let should_execute = self_always_execute + || is_recursive + || !(file.args.dry_run || file.args.question || file.args.touch); if !should_execute { return Ok(()); } diff --git a/src/makefile/token.rs b/src/makefile/token.rs index 294e80d..2f90f50 100644 --- a/src/makefile/token.rs +++ b/src/makefile/token.rs @@ -155,6 +155,15 @@ impl fmt::Display for TokenString { } } +impl PartialEq for TokenString { + fn eq(&self, other: &str) -> bool { + match self.0.as_slice() { + [Token::Text(x)] => x == other, + _ => false, + } + } +} + #[derive(PartialEq, Eq, Clone, Debug)] pub enum Token { Text(String), -- cgit v1.2.3