Skip to content

Commit

Permalink
Auto merge of #50374 - petrochenkov:pypath, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
rustbuild: Normalize paths coming from Python slightly

Fixes #49785
  • Loading branch information
bors committed May 1, 2018
2 parents 4d7bbdd + 993f7c5 commit 1fd74eb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,14 @@ struct TomlTarget {
}

impl Config {
fn path_from_python(var_key: &str) -> PathBuf {
match env::var_os(var_key) {
// Do not trust paths from Python and normalize them slightly (#49785).
Some(var_val) => Path::new(&var_val).components().collect(),
_ => panic!("expected '{}' to be set", var_key),
}
}

pub fn default_opts() -> Config {
let mut config = Config::default();
config.llvm_enabled = true;
Expand All @@ -348,9 +356,9 @@ impl Config {
config.deny_warnings = true;

// set by bootstrap.py
config.src = env::var_os("SRC").map(PathBuf::from).expect("'SRC' to be set");
config.build = INTERNER.intern_str(&env::var("BUILD").expect("'BUILD' to be set"));
config.out = env::var_os("BUILD_DIR").map(PathBuf::from).expect("'BUILD_DIR' set");
config.src = Config::path_from_python("SRC");
config.out = Config::path_from_python("BUILD_DIR");

let stage0_root = config.out.join(&config.build).join("stage0/bin");
config.initial_rustc = stage0_root.join(exe("rustc", &config.build));
Expand Down

0 comments on commit 1fd74eb

Please sign in to comment.