use std::mem;
use std::process::{self, Output};
+use rustc_back::LldFlavor;
+
#[derive(Clone)]
pub struct Command {
program: Program,
enum Program {
Normal(OsString),
CmdBatScript(OsString),
+ Lld(OsString, LldFlavor)
}
impl Command {
Command::_new(Program::CmdBatScript(program.as_ref().to_owned()))
}
+ pub fn lld<P: AsRef<OsStr>>(program: P, flavor: LldFlavor) -> Command {
+ Command::_new(Program::Lld(program.as_ref().to_owned(), flavor))
+ }
+
fn _new(program: Program) -> Command {
Command {
program,
self
}
- pub fn envs<I, K, V>(&mut self, envs: I) -> &mut Command
- where I: IntoIterator<Item=(K, V)>,
- K: AsRef<OsStr>,
- V: AsRef<OsStr>
- {
- for (key, value) in envs {
- self._env(key.as_ref(), value.as_ref());
- }
- self
- }
-
fn _env(&mut self, key: &OsStr, value: &OsStr) {
self.env.push((key.to_owned(), value.to_owned()));
}
c.arg("/c").arg(p);
c
}
+ Program::Lld(ref p, flavor) => {
+ let mut c = process::Command::new(p);
+ c.arg("-flavor").arg(match flavor {
+ LldFlavor::Wasm => "wasm",
+ LldFlavor::Ld => "gnu",
+ LldFlavor::Link => "link",
+ LldFlavor::Ld64 => "darwin",
+ });
+ c
+ }
};
ret.args(&self.args);
ret.envs(self.env.clone());
// extensions
+ pub fn get_args(&self) -> &[OsString] {
+ &self.args
+ }
+
pub fn take_args(&mut self) -> Vec<OsString> {
mem::replace(&mut self.args, Vec::new())
}