diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 465ebf846d3..8a38fedc613 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -275,7 +275,12 @@ Arguments: }; // Get any optional paths which occur after the subcommand let cwd = t!(env::current_dir()); - let paths = matches.free[1..].iter().map(|p| cwd.join(p)).collect::>(); + let src = matches.opt_str("src").map(PathBuf::from) + .or_else(|| env::var_os("SRC").map(PathBuf::from)) + .unwrap_or(cwd.clone()); + let paths = matches.free[1..].iter().map(|p| { + cwd.join(p).strip_prefix(&src).expect("paths passed to be inside checkout").into() + }).collect::>(); let cfg_file = matches.opt_str("config").map(PathBuf::from).or_else(|| { if fs::metadata("config.toml").is_ok() { @@ -360,10 +365,6 @@ Arguments: stage = Some(1); } - let src = matches.opt_str("src").map(PathBuf::from) - .or_else(|| env::var_os("SRC").map(PathBuf::from)) - .unwrap_or(cwd.clone()); - Flags { verbose: matches.opt_count("verbose"), stage, @@ -375,12 +376,14 @@ Arguments: target: split(matches.opt_strs("target")) .into_iter().map(|x| INTERNER.intern_string(x)).collect::>(), config: cfg_file, - src, jobs: matches.opt_str("jobs").map(|j| j.parse().unwrap()), cmd, incremental: matches.opt_present("incremental"), exclude: split(matches.opt_strs("exclude")) - .into_iter().map(|p| cwd.join(p)).collect::>(), + .into_iter().map(|p| { + cwd.join(p).strip_prefix(&src).expect("paths to be inside checkout").into() + }).collect::>(), + src, } } }