1use std::{
2 ffi::OsString,
3 path::{Path, PathBuf},
4 process::Command,
5};
6
7#[derive(Clone, Debug)]
9pub struct Tool {
10 pub(crate) tool: PathBuf,
11 pub(crate) is_clang_cl: bool,
12 pub(crate) env: Vec<(OsString, OsString)>,
13}
14
15impl Tool {
16 pub fn to_command(&self) -> Command {
22 let mut cmd = Command::new(&self.tool);
23
24 for (k, v) in self.env.iter() {
25 cmd.env(k, v);
26 }
27
28 cmd
29 }
30
31 pub fn is_clang_cl(&self) -> bool {
33 self.is_clang_cl
34 }
35
36 pub fn path(&self) -> &Path {
38 &self.tool
39 }
40
41 pub fn env(&self) -> impl IntoIterator<Item = &(OsString, OsString)> {
43 &self.env
44 }
45}