aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2024-12-17 21:01:47 -0700
committerMelody Horn <melody@boringcactus.com>2024-12-17 21:01:47 -0700
commitb59dcd1cf227345fce63a4202a5c10e21e7e29bd (patch)
treea96f7f99114672751e28b32ae9b34e526be1d63d /src
parent5947cb97b51b5bbd78ec4213bff8541e3167e737 (diff)
downloadmakers-b59dcd1cf227345fce63a4202a5c10e21e7e29bd.tar.gz
makers-b59dcd1cf227345fce63a4202a5c10e21e7e29bd.zip
don't fail inference if a missing dependency is .PHONY
Diffstat (limited to 'src')
-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(())
+ }
}