Skip to content

Commit 5fb5254

Browse files
bors[bot]RalfJung
andcommitted
Merge #246
246: let environment overwrite cargo command r=jethrogb a=RalfJung This is needed in rust-lang/rust#63162 to make xargo work during rustc bootstrap. r? @jethrogb Co-authored-by: Ralf Jung <post@ralfj.de>
2 parents a11f3d3 + c48cc75 commit 5fb5254

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/cargo.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,14 @@ fn flags(config: Option<&Config>, target: &str, tool: &str) -> Result<Vec<String
142142
}
143143
}
144144

145+
pub fn command() -> Command {
146+
env::var_os("CARGO")
147+
.map(Command::new)
148+
.unwrap_or_else(|| Command::new("cargo"))
149+
}
150+
145151
pub fn run(args: &Args, verbose: bool) -> Result<ExitStatus> {
146-
Command::new("cargo")
152+
command()
147153
.args(args.all())
148154
.run_and_get_status(verbose)
149155
}

src/sysroot.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::collections::hash_map::DefaultHasher;
33
use std::hash::{Hash, Hasher};
44
use std::io::{self, Write};
55
use std::path::PathBuf;
6-
use std::process::Command;
76
use std::{env, fs};
87

98
use rustc_version::VersionMeta;
@@ -104,7 +103,7 @@ version = "0.0.0"
104103
util::write(&td.join("src/lib.rs"), "")?;
105104

106105
let cargo = || {
107-
let mut cmd = Command::new("cargo");
106+
let mut cmd = cargo::command();
108107
let mut flags = rustflags.for_xargo(home);
109108
flags.push_str(" -Z force-unstable-if-unmarked");
110109
if verbose {

src/xargo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::path::{Display, PathBuf};
2-
use std::process::{Command, ExitStatus};
2+
use std::process::ExitStatus;
33
use std::{env, mem};
44
use std::io::{self, Write};
55

@@ -23,7 +23,7 @@ pub fn run(
2323
config: Option<&Config>,
2424
verbose: bool,
2525
) -> Result<ExitStatus> {
26-
let mut cmd = Command::new("cargo");
26+
let mut cmd = cargo::command();
2727
cmd.args(args.all());
2828

2929
if args.subcommand() == Some(Subcommand::Doc) {

0 commit comments

Comments
 (0)