aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/inference_rules.rs
blob: 397008b0dfbf4ed4b222e9505dd06e4ba1df1f96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use std::fmt;

use crate::makefile::command_line::CommandLine;

#[derive(PartialEq, Eq, Clone, Debug)]
pub(crate) struct InferenceRule {
    /// POSIX calls this ".s1" but that's not useful.
    pub(crate) product: String,
    /// POSIX calls this ".s2" but that's not useful.
    pub(crate) prereq: String,
    pub(crate) commands: Vec<CommandLine>,
}

impl fmt::Display for InferenceRule {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        writeln!(f, "{}{}:", &self.prereq, &self.product)?;
        for command in &self.commands {
            writeln!(f, "\t{}", command)?;
        }
        Ok(())
    }
}