aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/inference_rules.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-14 11:51:38 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-14 11:51:38 -0600
commit457bcbfd1116f0b3330f9b409395beabffe6ca18 (patch)
tree4da7a70bc154920ccf7671c12008e005aabfe4a1 /src/makefile/inference_rules.rs
parentbec9464713379c922ef728e52b37fc7434444b32 (diff)
downloadmakers-457bcbfd1116f0b3330f9b409395beabffe6ca18.tar.gz
makers-457bcbfd1116f0b3330f9b409395beabffe6ca18.zip
keep track of sources for inference rules too
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(),