summaryrefslogtreecommitdiffstats
path: root/third_party/rust/bindgen/deps.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/bindgen/deps.rs')
-rw-r--r--third_party/rust/bindgen/deps.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/third_party/rust/bindgen/deps.rs b/third_party/rust/bindgen/deps.rs
new file mode 100644
index 0000000000..987225b28e
--- /dev/null
+++ b/third_party/rust/bindgen/deps.rs
@@ -0,0 +1,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)
+ }
+}