Skip to content

Commit

Permalink
Rollup merge of rust-lang#42695 - Mark-Simulacrum:fix-verbose, r=alex…
Browse files Browse the repository at this point in the history
…crichton

Use custom cargo/rustc paths when parsing flags.

Fixes rust-lang#41779, probably also rust-lang#42543 (I think they're duplicates).

I'm not entirely happy with the implementation, since it means we parse the configuration twice, but it's the minimal solution. I think the other choice is to move both calls to Config::parse inside Flags::parse and merge them, but I don't know if that's a good idea.

r? @alexcrichton
  • Loading branch information
frewsxcv committed Jun 18, 2017
2 parents 28cc0c5 + 7326737 commit 998ee7b
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,18 @@ Arguments:
let cwd = t!(env::current_dir());
let paths = matches.free[1..].iter().map(|p| cwd.join(p)).collect::<Vec<_>>();

let cfg_file = matches.opt_str("config").map(PathBuf::from).or_else(|| {
if fs::metadata("config.toml").is_ok() {
Some(PathBuf::from("config.toml"))
} else {
None
}
});

// All subcommands can have an optional "Available paths" section
if matches.opt_present("verbose") {
let flags = Flags::parse(&["build".to_string()]);
let mut config = Config::default();
let mut config = Config::parse(&flags.build, cfg_file.clone());
config.build = flags.build.clone();
let mut build = Build::new(flags, config);
metadata::build(&mut build);
Expand Down Expand Up @@ -307,14 +314,6 @@ Arguments:
};


let cfg_file = matches.opt_str("config").map(PathBuf::from).or_else(|| {
if fs::metadata("config.toml").is_ok() {
Some(PathBuf::from("config.toml"))
} else {
None
}
});

let mut stage = matches.opt_str("stage").map(|j| j.parse().unwrap());

if matches.opt_present("incremental") {
Expand Down

0 comments on commit 998ee7b

Please sign in to comment.