use std::path::{Path, PathBuf};
use std::process::Command;
use crate::{env_var, handle_failed_output};
pub fn llvm_readobj() -> LlvmReadobj {
LlvmReadobj::new()
}
#[derive(Debug)]
pub struct LlvmReadobj {
cmd: Command,
}
crate::impl_common_helpers!(LlvmReadobj);
impl LlvmReadobj {
pub fn new() -> Self {
let llvm_bin_dir = env_var("LLVM_BIN_DIR");
let llvm_bin_dir = PathBuf::from(llvm_bin_dir);
let llvm_readobj = llvm_bin_dir.join("llvm-readobj");
let cmd = Command::new(llvm_readobj);
Self { cmd }
}
pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg(path.as_ref());
self
}
pub fn file_header(&mut self) -> &mut Self {
self.cmd.arg("--file-header");
self
}
#[track_caller]
pub fn command_output(&mut self) -> ::std::process::Output {
self.cmd.output().expect("failed to get output of finished process")
}
}