summaryrefslogtreecommitdiffstats
path: root/third_party/rust/bindgen/deps.rs
blob: 987225b28eb91279f43235236f559661d70dd2c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/// Generating build depfiles from parsed bindings.
use std::{collections::BTreeSet, path::PathBuf};

#[derive(Clone, Debug)]
pub(crate) struct DepfileSpec {
    pub output_module: String,
    pub depfile_path: PathBuf,
}

impl DepfileSpec {
    pub fn write(&self, deps: &BTreeSet<String>) -> std::io::Result<()> {
        let mut buf = format!("{}:", self.output_module);

        for file in deps {
            buf = format!("{} {}", buf, file);
        }

        std::fs::write(&self.depfile_path, &buf)
    }
}