Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Rust master: Update process_builder to use the new Command builder API. #14

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cargo/core/dependency.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use semver::Version;
use core::{NameVer,VersionReq};
use core::VersionReq;
use util::CargoResult;

#[deriving(Eq,Clone,Show)]
Expand Down
32 changes: 16 additions & 16 deletions src/cargo/util/process_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fmt;
use std::fmt::{Show,Formatter};
use std::os;
use std::path::Path;
use std::io::process::{Process,ProcessConfig,ProcessOutput,InheritFd};
use std::io::process::{Command,ProcessOutput,InheritFd};
use util::{CargoResult,io_error,process_error};
use collections::HashMap;

Expand Down Expand Up @@ -53,16 +53,16 @@ impl ProcessBuilder {

// TODO: should InheritFd be hardcoded?
pub fn exec(&self) -> CargoResult<()> {
let mut config = try!(self.build_config());
let mut command = try!(self.build_command());
let env = self.build_env();

// Set where the output goes
config.env = Some(env.as_slice());
config.stdout = InheritFd(1);
config.stderr = InheritFd(2);
command.env(env.as_slice())
.stdout(InheritFd(1))
.stderr(InheritFd(2));

let mut process = try!(Process::configure(config).map_err(io_error));
let exit = process.wait();
let mut process = try!(command.spawn().map_err(io_error));
let exit = process.wait().unwrap();

if exit.success() {
Ok(())
Expand All @@ -73,12 +73,13 @@ impl ProcessBuilder {
}

pub fn exec_with_output(&self) -> CargoResult<ProcessOutput> {
let mut config = try!(self.build_config());
let mut command = try!(self.build_command());
let env = self.build_env();

config.env = Some(env.as_slice());
// Set the environment
command.env(env.as_slice());

let output = try!(Process::configure(config).map(|mut ok| ok.wait_with_output()).map_err(io_error));
let output = try!(command.spawn().map(|ok| ok.wait_with_output()).map_err(io_error)).unwrap();

if output.status.success() {
Ok(output)
Expand All @@ -88,14 +89,13 @@ impl ProcessBuilder {
}
}

fn build_config<'a>(&'a self) -> CargoResult<ProcessConfig<'a>> {
let mut config = ProcessConfig::new();
fn build_command(&self) -> CargoResult<Command> {
let mut command = Command::new(self.program.as_slice());

config.program = self.program.as_slice();
config.args = self.args.as_slice();
config.cwd = Some(&self.cwd);
command.args(self.args.as_slice())
.cwd(&self.cwd);

Ok(config)
Ok(command)
}

fn debug_string(&self) -> ~str {
Expand Down