From 457bcbfd1116f0b3330f9b409395beabffe6ca18 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Wed, 14 Apr 2021 11:51:38 -0600 Subject: keep track of sources for inference rules too --- src/makefile/inference_rules.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/makefile/inference_rules.rs') diff --git a/src/makefile/inference_rules.rs b/src/makefile/inference_rules.rs index 397e651..368d72b 100644 --- a/src/makefile/inference_rules.rs +++ b/src/makefile/inference_rules.rs @@ -5,9 +5,11 @@ use regex::Captures; use super::command_line::CommandLine; use super::pattern::r#match; +use super::ItemSource; #[derive(PartialEq, Eq, Clone, Debug)] pub struct InferenceRule { + pub source: ItemSource, pub products: Vec, pub prerequisites: Vec, pub commands: Vec, @@ -15,8 +17,14 @@ pub struct InferenceRule { impl InferenceRule { /// s1 is the product, s2 is the prereq - pub fn new_suffix(s1: String, s2: String, commands: Vec) -> Self { + pub fn new_suffix( + source: ItemSource, + s1: String, + s2: String, + commands: Vec, + ) -> Self { Self { + source, products: vec![format!("%{}", s1)], prerequisites: vec![format!("%{}", s2)], commands, @@ -72,7 +80,12 @@ mod test { #[test] fn suffix_match() -> R { - let rule = InferenceRule::new_suffix(".o".to_owned(), ".c".to_owned(), vec![]); + let rule = InferenceRule::new_suffix( + ItemSource::Builtin, + ".o".to_owned(), + ".c".to_owned(), + vec![], + ); assert!(rule.matches("foo.o")?); assert!(rule.matches("dir/foo.o")?); Ok(()) @@ -83,6 +96,7 @@ mod test { fn percent_match() -> R { // thanks, SPDX License List let rule = InferenceRule { + source: ItemSource::Builtin, products: vec!["licenseListPublisher-%.jar-valid".to_owned()], prerequisites: vec![ "licenseListPublisher-%.jar.asc".to_owned(), -- cgit v1.2.3