Avoid hard-coding rustc path in prepare.rs

This commit is contained in:
bjorn3 2023-02-12 14:28:09 +00:00
parent b1d8b7186c
commit 22befab611
2 changed files with 9 additions and 9 deletions

View File

@ -149,7 +149,7 @@ pub(crate) fn main() {
} }
if command == Command::Prepare { if command == Command::Prepare {
prepare::prepare(&dirs); prepare::prepare(&dirs, &bootstrap_host_compiler.rustc);
process::exit(0); process::exit(0);
} }

View File

@ -9,19 +9,19 @@
use super::tests::LIBCORE_TESTS_SRC; use super::tests::LIBCORE_TESTS_SRC;
use super::utils::{copy_dir_recursively, git_command, retry_spawn_and_wait, spawn_and_wait}; use super::utils::{copy_dir_recursively, git_command, retry_spawn_and_wait, spawn_and_wait};
pub(crate) fn prepare(dirs: &Dirs) { pub(crate) fn prepare(dirs: &Dirs, rustc: &Path) {
RelPath::DOWNLOAD.ensure_fresh(dirs); RelPath::DOWNLOAD.ensure_fresh(dirs);
prepare_stdlib(dirs); prepare_stdlib(dirs, rustc);
prepare_coretests(dirs); prepare_coretests(dirs, rustc);
super::tests::RAND_REPO.fetch(dirs); super::tests::RAND_REPO.fetch(dirs);
super::tests::REGEX_REPO.fetch(dirs); super::tests::REGEX_REPO.fetch(dirs);
super::tests::PORTABLE_SIMD_REPO.fetch(dirs); super::tests::PORTABLE_SIMD_REPO.fetch(dirs);
} }
fn prepare_stdlib(dirs: &Dirs) { fn prepare_stdlib(dirs: &Dirs, rustc: &Path) {
let sysroot_src_orig = get_default_sysroot(Path::new("rustc")).join("lib/rustlib/src/rust"); let sysroot_src_orig = get_default_sysroot(rustc).join("lib/rustlib/src/rust");
assert!(sysroot_src_orig.exists()); assert!(sysroot_src_orig.exists());
eprintln!("[COPY] stdlib src"); eprintln!("[COPY] stdlib src");
@ -36,7 +36,7 @@ fn prepare_stdlib(dirs: &Dirs) {
&SYSROOT_SRC.to_path(dirs).join("library"), &SYSROOT_SRC.to_path(dirs).join("library"),
); );
let rustc_version = get_rustc_version(Path::new("rustc")); let rustc_version = get_rustc_version(rustc);
fs::write(SYSROOT_RUSTC_VERSION.to_path(dirs), &rustc_version).unwrap(); fs::write(SYSROOT_RUSTC_VERSION.to_path(dirs), &rustc_version).unwrap();
eprintln!("[GIT] init"); eprintln!("[GIT] init");
@ -45,8 +45,8 @@ fn prepare_stdlib(dirs: &Dirs) {
apply_patches(dirs, "stdlib", &SYSROOT_SRC.to_path(dirs)); apply_patches(dirs, "stdlib", &SYSROOT_SRC.to_path(dirs));
} }
fn prepare_coretests(dirs: &Dirs) { fn prepare_coretests(dirs: &Dirs, rustc: &Path) {
let sysroot_src_orig = get_default_sysroot(Path::new("rustc")).join("lib/rustlib/src/rust"); let sysroot_src_orig = get_default_sysroot(rustc).join("lib/rustlib/src/rust");
assert!(sysroot_src_orig.exists()); assert!(sysroot_src_orig.exists());
eprintln!("[COPY] coretests src"); eprintln!("[COPY] coretests src");