aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/input.rs
diff options
context:
space:
mode:
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 {