diff options
author | Melody Horn <melody@boringcactus.com> | 2021-04-06 21:16:37 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-04-06 21:16:37 -0600 |
commit | 1216aceec6e007fbb84d1358e28be7b573c66501 (patch) | |
tree | 35e2cfafba6a99b5bbc0ef9e52ee8a1bd9daf744 | |
parent | 06eeecc0defec91a6e0fa8eb4acff27a59785e66 (diff) | |
download | makers-1216aceec6e007fbb84d1358e28be7b573c66501.tar.gz makers-1216aceec6e007fbb84d1358e28be7b573c66501.zip |
implement GNUful Static Pattern Rules
-rw-r--r-- | src/makefile/input.rs | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/makefile/input.rs b/src/makefile/input.rs index 9c895e1..460a8a0 100644 --- a/src/makefile/input.rs +++ b/src/makefile/input.rs @@ -474,6 +474,16 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> { let (targets, not_targets) = line_tokens .split_once(':') .ok_or_else(|| eyre!("read_rule couldn't find a ':' on line {}", line_number))?; + #[cfg(feature = "full")] + let (static_targets, targets, not_targets) = if not_targets.contains_text(":") { + // ugh, this is probably a Static Pattern Rule + let (pattern, not_targets) = not_targets + .split_once(':') + .ok_or_else(|| eyre!("bro hold the fuck up it literally just had that"))?; + (Some(targets), pattern, not_targets) + } else { + (None, targets, not_targets) + }; let targets = self.expand_macros(&targets)?; let targets = targets.split_whitespace().collect::<Vec<_>>(); let (prerequisites, mut commands) = match not_targets.split_once(';') { @@ -534,7 +544,26 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> { commands, }; - self.inference_rules.push(new_rule); + if let Some(static_targets) = static_targets { + let static_targets = self.expand_macros(&static_targets)?; + let static_targets = static_targets.split_whitespace(); + for real_target in static_targets { + if new_rule.matches(real_target)? { + let new_target = Target { + name: real_target.to_owned(), + prerequisites: new_rule.prereqs(real_target)?.collect(), + commands: new_rule.commands.clone(), + stem: new_rule + .first_match(real_target)? + .and_then(|x| x.get(1).map(|x| x.as_str().to_owned())), + already_updated: Cell::new(false), + }; + self.targets.insert(real_target.to_owned(), new_target); + } + } + } else { + self.inference_rules.push(new_rule); + } return Ok(()); } |