aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/makefile/mod.rs43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs
index 4d43d5b..c37e948 100644
--- a/src/makefile/mod.rs
+++ b/src/makefile/mod.rs
@@ -240,7 +240,10 @@ impl<'a> Makefile<'a> {
// we can't build this based on itself! fuck outta here
return None;
}
- if self.targets.has(&prereq_path_name) {
+ if self.targets.has(&prereq_path_name)
+ || self.special_target_has_prereq(".PHONY", &prereq_path_name)
+ {
+ // TODO consider only checking phony after transitive inference has failed
return Some(prereq_path_name);
}
let prereq_path = PathBuf::from(&prereq_path_name);
@@ -553,4 +556,42 @@ mod test {
assert!(file.update_target("all").is_ok());
Ok(())
}
+
+ #[cfg(feature = "full")]
+ #[test]
+ fn missing_phony_targets_allow_inference() -> R {
+ let args = Args::empty();
+ let rule = InferenceRule {
+ source: ItemSource::CommandLineOrMakeflags,
+ products: vec!["%ll".to_owned()],
+ prerequisites: vec!["missing".to_owned()],
+ commands: vec![],
+ macros: MacroSet::new(),
+ };
+ let phony = Target {
+ name: ".PHONY".to_string(),
+ prerequisites: vec!["missing".to_owned()],
+ commands: vec![],
+ stem: None,
+ already_updated: Cell::new(false),
+ macros: MacroSet::new(),
+ };
+
+ let mut inference_rules = InferenceRuleSet::default();
+ inference_rules.put(rule);
+ let targets = DynamicTargetSet::default();
+ targets.put(phony);
+ let file = Makefile {
+ inference_rules,
+ builtin_inference_rules: vec![],
+ macros: MacroSet::new(),
+ targets,
+ first_non_special_target: None,
+ args: &args,
+ already_inferred: Default::default(),
+ };
+
+ file.update_target("all")?;
+ Ok(())
+ }
}