about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorTim Neumann <mail@timnn.me>2016-10-31 21:00:32 +0100
committerTim Neumann <mail@timnn.me>2016-10-31 22:44:52 +0100
commit5cb5c85152e2a8b7f3480a46f4619b572f162056 (patch)
tree638b29c929f921c17f86c848168f4817e7a35cb9 /src
parentdce460028e9c21ebadb28f6744d4b10bf0e8d501 (diff)
downloadrust-5cb5c85152e2a8b7f3480a46f4619b572f162056.tar.gz
rust-5cb5c85152e2a8b7f3480a46f4619b572f162056.zip
rustbuild+configure: improve bin/exe joining
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/config.rs8
-rw-r--r--src/bootstrap/util.rs18
2 files changed, 23 insertions, 3 deletions
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index 0948a7c130e..9f6e91c8566 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -23,6 +23,7 @@ use std::process;
 use num_cpus;
 use rustc_serialize::Decodable;
 use toml::{Parser, Decoder, Value};
+use util::push_exe_path;
 
 /// Global configuration for the entire build and/or bootstrap.
 ///
@@ -417,7 +418,7 @@ impl Config {
                     let target = self.target_config.entry(self.build.clone())
                                      .or_insert(Target::default());
                     let root = PathBuf::from(value);
-                    target.llvm_config = Some(root.join("bin/llvm-config"));
+                    target.llvm_config = Some(push_exe_path(root, &["bin", "llvm-config"]));
                 }
                 "CFG_JEMALLOC_ROOT" if value.len() > 0 => {
                     let target = self.target_config.entry(self.build.clone())
@@ -449,8 +450,9 @@ impl Config {
                     target.ndk = Some(PathBuf::from(value));
                 }
                 "CFG_LOCAL_RUST_ROOT" if value.len() > 0 => {
-                    self.rustc = Some(PathBuf::from(value).join("bin/rustc"));
-                    self.cargo = Some(PathBuf::from(value).join("bin/cargo"));
+                    let path = PathBuf::from(value);
+                    self.rustc = Some(push_exe_path(path.clone(), &["bin", "rustc"]));
+                    self.cargo = Some(push_exe_path(path, &["bin", "cargo"]));
                 }
                 _ => {}
             }
diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs
index 6c0a32a54d9..84ba03b2502 100644
--- a/src/bootstrap/util.rs
+++ b/src/bootstrap/util.rs
@@ -172,3 +172,21 @@ pub fn dylib_path() -> Vec<PathBuf> {
     env::split_paths(&env::var_os(dylib_path_var()).unwrap_or(OsString::new()))
         .collect()
 }
+
+/// `push` all components to `buf`. On windows, append `.exe` to the last component.
+pub fn push_exe_path(mut buf: PathBuf, components: &[&str]) -> PathBuf {
+    let (&file, components) = components.split_last().expect("at least one component required");
+    let mut file = file.to_owned();
+
+    if cfg!(windows) {
+        file.push_str(".exe");
+    }
+
+    for c in components {
+        buf.push(c);
+    }
+
+    buf.push(file);
+
+    buf
+}