diff options
author | Melody Horn <melody@boringcactus.com> | 2024-11-13 19:52:03 -0700 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2024-11-13 19:52:03 -0700 |
commit | d46ac4d95dd5ffa165ad0de6d883c076289c5169 (patch) | |
tree | 97e3213e330a6539cee147aff7a62505bf0f140b /src/makefile | |
parent | f0f65f5c9672390eb0047b0faa411e53898e9c71 (diff) | |
download | makers-d46ac4d95dd5ffa165ad0de6d883c076289c5169.tar.gz makers-d46ac4d95dd5ffa165ad0de6d883c076289c5169.zip |
let ./%.o match foo.o in a really ugly way
Diffstat (limited to 'src/makefile')
-rw-r--r-- | src/makefile/inference_rules.rs | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/makefile/inference_rules.rs b/src/makefile/inference_rules.rs index d7db1e6..7f77bd7 100644 --- a/src/makefile/inference_rules.rs +++ b/src/makefile/inference_rules.rs @@ -36,7 +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| r#match(pattern, target_name)) + .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) + }) .try_fold(None, |x, y| y.map(|y| x.or(y))) } @@ -196,4 +199,32 @@ mod test { assert!(rule.matches("licenseListPublisher-2.2.1.jar-valid")?); Ok(()) } + + #[cfg(feature = "full")] + #[test] + fn subdir_match() -> R { + let rule = InferenceRule { + source: ItemSource::Builtin, + products: vec!["a/%.o".to_owned()], + prerequisites: vec!["a/%.c".to_owned()], + commands: vec![], + macros: MacroSet::new(), + }; + assert!(rule.matches("a/foo.o")?); + Ok(()) + } + + #[cfg(feature = "full")] + #[test] + fn self_subdir_match() -> R { + let rule = InferenceRule { + source: ItemSource::Builtin, + products: vec!["./%.o".to_owned()], + prerequisites: vec!["./%.c".to_owned()], + commands: vec![], + macros: MacroSet::new(), + }; + assert!(rule.matches("foo.o")?); + Ok(()) + } } |