aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2024-12-18 23:43:54 -0700
committerMelody Horn <melody@boringcactus.com>2024-12-18 23:43:54 -0700
commitc642441492feb8e9d7bbcc45c6507540cfc6738f (patch)
tree962295d7e0f5c740f717bdf2b11d72c801a24470
parentad2d35f273403469e64ca8ccc3d2ba594609fa30 (diff)
downloadmakers-canon.tar.gz
makers-canon.zip
let ./egg% match ./eggbug and not just eggbugHEADcanon
-rw-r--r--src/makefile/inference_rules.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/makefile/inference_rules.rs b/src/makefile/inference_rules.rs
index 7f77bd7..f841797 100644
--- a/src/makefile/inference_rules.rs
+++ b/src/makefile/inference_rules.rs
@@ -36,10 +36,10 @@ impl InferenceRule {
pub fn first_match<'s, 't: 's>(&'s self, target_name: &'t str) -> Result<Option<Captures<'t>>> {
self.products
.iter()
- .map(|pattern| {
- // TODO find a better way to make the self_subdir_match test pass
- r#match(pattern.strip_prefix("./").unwrap_or(pattern), target_name)
- })
+ // TODO find a better way to make the self_subdir_match test pass
+ .flat_map(|pattern| [pattern.strip_prefix("./"), Some(pattern.as_str())])
+ .filter_map(|x| x)
+ .map(|pattern| r#match(pattern, target_name))
.try_fold(None, |x, y| y.map(|y| x.or(y)))
}
@@ -225,6 +225,7 @@ mod test {
macros: MacroSet::new(),
};
assert!(rule.matches("foo.o")?);
+ assert!(rule.matches("./foo.o")?);
Ok(())
}
}