aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/inference_rules.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/makefile/inference_rules.rs')
-rw-r--r--src/makefile/inference_rules.rs18
1 files changed, 16 insertions, 2 deletions
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<String>,
pub prerequisites: Vec<String>,
pub commands: Vec<CommandLine>,
@@ -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<CommandLine>) -> Self {
+ pub fn new_suffix(
+ source: ItemSource,
+ s1: String,
+ s2: String,
+ commands: Vec<CommandLine>,
+ ) -> 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(),