]> git.lizzy.rs Git - rust.git/blob - src/bootstrap/build.rs
Rollup merge of #89422 - GuillaumeGomez:doctest-whitespace-name, r=CraftSpider
[rust.git] / src / bootstrap / build.rs
1 use std::env;
2 use std::path::PathBuf;
3
4 fn main() {
5     println!("cargo:rerun-if-changed=build.rs");
6     println!("cargo:rustc-env=BUILD_TRIPLE={}", env::var("HOST").unwrap());
7
8     // This may not be a canonicalized path.
9     let mut rustc = PathBuf::from(env::var_os("RUSTC").unwrap());
10
11     if rustc.is_relative() {
12         for dir in env::split_paths(&env::var_os("PATH").unwrap_or_default()) {
13             let absolute = dir.join(&rustc);
14             if absolute.exists() {
15                 rustc = absolute;
16                 break;
17             }
18         }
19     }
20     assert!(rustc.is_absolute());
21
22     // FIXME: if the path is not utf-8, this is going to break. Unfortunately
23     // Cargo doesn't have a way for us to specify non-utf-8 paths easily, so
24     // we'll need to invent some encoding scheme if this becomes a problem.
25     println!("cargo:rustc-env=RUSTC={}", rustc.to_str().unwrap());
26 }