]> git.proxmox.com Git - rustc.git/blob - src/bootstrap/build.rs
New upstream version 1.61.0+dfsg1
[rustc.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:rerun-if-env-changed=RUSTC");
7 println!("cargo:rustc-env=BUILD_TRIPLE={}", env::var("HOST").unwrap());
8
9 // This may not be a canonicalized path.
10 let mut rustc = PathBuf::from(env::var_os("RUSTC").unwrap());
11
12 if rustc.is_relative() {
13 println!("cargo:rerun-if-env-changed=PATH");
14 for dir in env::split_paths(&env::var_os("PATH").unwrap_or_default()) {
15 let absolute = dir.join(&rustc);
16 if absolute.exists() {
17 rustc = absolute;
18 break;
19 }
20 }
21 }
22 assert!(rustc.is_absolute());
23
24 // FIXME: if the path is not utf-8, this is going to break. Unfortunately
25 // Cargo doesn't have a way for us to specify non-utf-8 paths easily, so
26 // we'll need to invent some encoding scheme if this becomes a problem.
27 println!("cargo:rustc-env=RUSTC={}", rustc.to_str().unwrap());
28 }