aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-15 00:19:09 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-15 00:19:09 -0600
commitdc9f24cd5b5cd9ae3e0aa86e661fc0cf30ac63ef (patch)
tree9fec52c771de52251dbefe20207272010e351d52
parentb162ce1d581d2f3352a2d878e037bd9949e9dace (diff)
downloadmakers-dc9f24cd5b5cd9ae3e0aa86e661fc0cf30ac63ef.tar.gz
makers-dc9f24cd5b5cd9ae3e0aa86e661fc0cf30ac63ef.zip
ignore missing targets if they're phony
shout out to the gnu make docs for never mentioning that this works this way
-rw-r--r--src/makefile/mod.rs48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs
index 981636b..764328f 100644
--- a/src/makefile/mod.rs
+++ b/src/makefile/mod.rs
@@ -326,7 +326,17 @@ impl<'a> Makefile<'a> {
}
pub fn update_target(&self, name: &str) -> Result<()> {
- self.get_target(name)?.borrow().update(self)
+ let target = self.get_target(name);
+ match target {
+ // TODO make this less janky
+ Err(err)
+ if err.to_string().contains(" not found!")
+ && self.special_target_has_prereq(".PHONY", name) =>
+ {
+ Ok(())
+ }
+ _ => target?.borrow().update(self),
+ }
}
fn expand_macros(&self, text: &TokenString, target: Option<&Target>) -> Result<String> {
@@ -535,4 +545,40 @@ mod test {
assert_eq!(target.borrow().stem, Some("test".to_owned()));
Ok(())
}
+
+ #[cfg(feature = "full")]
+ #[test]
+ fn missing_phony_targets_ignored() -> R {
+ let args = Args::empty();
+ let target = Target {
+ name: "all".to_owned(),
+ prerequisites: vec!["missing".to_owned()],
+ commands: vec![],
+ stem: None,
+ already_updated: Cell::new(false),
+ };
+ let phony = Target {
+ name: ".PHONY".to_string(),
+ prerequisites: vec!["missing".to_owned()],
+ commands: vec![],
+ stem: None,
+ already_updated: Cell::new(false),
+ };
+
+ let targets = DynamicTargetSet::default();
+ targets.put(target);
+ targets.put(phony);
+ let file = Makefile {
+ inference_rules: vec![],
+ builtin_inference_rules: vec![],
+ macros: MacroSet::new(),
+ targets,
+ first_non_special_target: None,
+ args: &args,
+ already_inferred: Default::default(),
+ };
+
+ assert!(file.update_target("all").is_ok());
+ Ok(())
+ }
}