aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/input.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-03 18:01:04 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-03 18:01:04 -0600
commitf73d0b2256f2afc05995929c930b2eeab6800ecf (patch)
tree8c580ae21e50a5d3c166a568bbc5955ffcb341ad /src/makefile/input.rs
parent7c2a09e5c75d87d5dd728623517899ca7cada630 (diff)
downloadmakers-f73d0b2256f2afc05995929c930b2eeab6800ecf.tar.gz
makers-f73d0b2256f2afc05995929c930b2eeab6800ecf.zip
implement GNUish '%'-based inference rules
Diffstat (limited to 'src/makefile/input.rs')
-rw-r--r--src/makefile/input.rs26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/makefile/input.rs b/src/makefile/input.rs
index 3abdb8b..3a3508f 100644
--- a/src/makefile/input.rs
+++ b/src/makefile/input.rs
@@ -375,19 +375,33 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
return Ok(());
}
- // we don't know yet if it's a target rule or an inference rule
+ // we don't know yet if it's a target rule or an inference rule (or a GNUish "pattern rule")
let inference_match = inference_match(&targets, &prerequisites);
+ #[cfg(feature = "full")]
+ let is_pattern = targets.iter().all(|x| x.contains('%'));
- if let Some(inference_match) = inference_match {
+ #[cfg(feature = "full")]
+ if is_pattern {
let new_rule = InferenceRule {
- product: inference_match.name("s1").unwrap().as_str().to_owned(),
- prereq: inference_match.name("s2").unwrap().as_str().to_owned(),
+ products: targets.into_iter().map(|x| x.to_owned()).collect(),
+ prerequisites,
commands,
};
+ self.inference_rules.push(new_rule);
+ return Ok(());
+ }
+
+ if let Some(inference_match) = inference_match {
+ let new_rule = InferenceRule::new_suffix(
+ inference_match.name("s1").unwrap().as_str().to_owned(),
+ inference_match.name("s2").unwrap().as_str().to_owned(),
+ commands,
+ );
+
self.inference_rules.retain(|existing_rule| {
- (&existing_rule.prereq, &existing_rule.product)
- != (&new_rule.prereq, &new_rule.product)
+ (&existing_rule.prerequisites, &existing_rule.products)
+ != (&new_rule.prerequisites, &new_rule.products)
});
self.inference_rules.push(new_rule);
} else {