diff options
author | Melody Horn <melody@boringcactus.com> | 2024-11-13 00:27:03 -0700 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2024-11-13 00:27:03 -0700 |
commit | 44b3ea4dac1cc60eeda54ae7b53facbb025c6f68 (patch) | |
tree | 48ea916afa45aaad161042efdaa771e6f7b5c1b6 /src/makefile/input.rs | |
parent | dfb51bfebd0d5c22e82d2a73412a19c3e0599524 (diff) | |
download | makers-44b3ea4dac1cc60eeda54ae7b53facbb025c6f68.tar.gz makers-44b3ea4dac1cc60eeda54ae7b53facbb025c6f68.zip |
fix rule macro detection when macro expansion in macro name
Diffstat (limited to 'src/makefile/input.rs')
-rw-r--r-- | src/makefile/input.rs | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/src/makefile/input.rs b/src/makefile/input.rs index 2c4a6bb..865b68b 100644 --- a/src/makefile/input.rs +++ b/src/makefile/input.rs @@ -22,7 +22,6 @@ use super::parse::{MacroAssignment, MacroAssignmentOutcome}; use super::r#macro::ExportConfig; use super::r#macro::Macro; use super::target::StaticTargetSet; -use super::token::Token; use super::{ builtin_targets, CommandLine, InferenceRule, InferenceRuleSet, ItemSource, LookupInternal, MacroScopeStack, MacroSet, Target, TokenString, @@ -58,35 +57,31 @@ impl LineType { if line_tokens.starts_with("unexport ") || line_tokens == "unexport" { return Self::Unexport; } - for token in line_tokens.tokens() { - if let Token::Text(text) = token { - let colon_idx = text.find(':'); - #[cfg(not(feature = "full"))] - let equals_idx = text.find('='); + let colon_idx = line_tokens.find(":"); + #[cfg(not(feature = "full"))] + let equals_idx = line_tokens.find('='); + #[cfg(feature = "full")] + let equals_idx = ["=", ":=", "::=", "?=", "+="] + .iter() + .filter_map(|p| line_tokens.find(p)) + .min(); + match (colon_idx, equals_idx) { + (Some(_), None) => { + return Self::Rule; + } + (Some(c), Some(e)) if c < e => { #[cfg(feature = "full")] - let equals_idx = ["=", ":=", "::=", "?=", "+="] - .iter() - .filter_map(|p| text.find(p)) - .min(); - match (colon_idx, equals_idx) { - (Some(_), None) => { - return Self::Rule; - } - (Some(c), Some(e)) if c < e => { - #[cfg(feature = "full")] - return Self::RuleMacro; - #[cfg(not(feature = "full"))] - return Self::Rule; - } - (None, Some(_)) => { - return Self::Macro; - } - (Some(c), Some(e)) if e <= c => { - return Self::Macro; - } - _ => {} - } + return Self::RuleMacro; + #[cfg(not(feature = "full"))] + return Self::Rule; + } + (None, Some(_)) => { + return Self::Macro; + } + (Some(c), Some(e)) if e <= c => { + return Self::Macro; } + _ => {} } Self::Unknown } |