Set BUILD_TRIPLE via build script

This moves build triple discovery for rustbuild from bootstrap.py into a build
script, meaning it will "just work" if building rustbuild via Cargo rather than
Python.
This commit is contained in:
Mark Rousskov 2020-09-06 19:57:07 -04:00
parent 81e02708f1
commit 6d19561587
4 changed files with 5 additions and 2 deletions

View File

@ -3,6 +3,7 @@ authors = ["The Rust Project Developers"]
name = "bootstrap"
version = "0.0.0"
edition = "2018"
build = "build.rs"
[lib]
path = "lib.rs"

View File

@ -1032,7 +1032,6 @@ def bootstrap(help_triggered):
args = [build.bootstrap_binary()]
args.extend(sys.argv[1:])
env = os.environ.copy()
env["BUILD"] = build.build
env["SRC"] = build.rust_root
env["BOOTSTRAP_PARENT_ID"] = str(os.getpid())
env["BOOTSTRAP_PYTHON"] = sys.executable

3
src/bootstrap/build.rs Normal file
View File

@ -0,0 +1,3 @@
fn main() {
println!("cargo:rustc-env=BUILD_TRIPLE={}", std::env::var("HOST").unwrap());
}

View File

@ -487,7 +487,7 @@ impl Config {
config.missing_tools = false;
// set by bootstrap.py
config.build = TargetSelection::from_user(&env::var("BUILD").expect("'BUILD' to be set"));
config.build = TargetSelection::from_user(&env!("BUILD_TRIPLE"));
config.src = Config::path_from_python("SRC");
config.out = Config::path_from_python("BUILD_DIR");