Inline prepare_stdlib into the sysroot build code

Also reduce visibility of a couple of statics
This commit is contained in:
bjorn3 2024-09-12 19:02:13 +00:00
parent ade0e38b5e
commit 45be990167
4 changed files with 14 additions and 20 deletions

View File

@ -6,7 +6,7 @@ use crate::rustc_info::get_file_name;
use crate::shared_utils::{rustflags_from_env, rustflags_to_cmd_env}; use crate::shared_utils::{rustflags_from_env, rustflags_to_cmd_env};
use crate::utils::{CargoProject, Compiler, LogGroup}; use crate::utils::{CargoProject, Compiler, LogGroup};
pub(crate) static CG_CLIF: CargoProject = CargoProject::new(&RelPath::SOURCE, "cg_clif"); static CG_CLIF: CargoProject = CargoProject::new(&RelPath::SOURCE, "cg_clif");
pub(crate) fn build_backend( pub(crate) fn build_backend(
dirs: &Dirs, dirs: &Dirs,

View File

@ -3,7 +3,8 @@ use std::process::Command;
use std::{env, fs}; use std::{env, fs};
use crate::path::{Dirs, RelPath}; use crate::path::{Dirs, RelPath};
use crate::rustc_info::get_file_name; use crate::prepare::apply_patches;
use crate::rustc_info::{get_default_sysroot, get_file_name};
use crate::utils::{ use crate::utils::{
remove_dir_if_exists, spawn_and_wait, try_hard_link, CargoProject, Compiler, LogGroup, remove_dir_if_exists, spawn_and_wait, try_hard_link, CargoProject, Compiler, LogGroup,
}; };
@ -157,10 +158,10 @@ impl SysrootTarget {
} }
} }
pub(crate) static STDLIB_SRC: RelPath = RelPath::BUILD.join("stdlib"); static STDLIB_SRC: RelPath = RelPath::BUILD.join("stdlib");
pub(crate) static STANDARD_LIBRARY: CargoProject = static STANDARD_LIBRARY: CargoProject =
CargoProject::new(&STDLIB_SRC.join("library/sysroot"), "stdlib_target"); CargoProject::new(&STDLIB_SRC.join("library/sysroot"), "stdlib_target");
pub(crate) static RTSTARTUP_SYSROOT: RelPath = RelPath::BUILD.join("rtstartup"); static RTSTARTUP_SYSROOT: RelPath = RelPath::BUILD.join("rtstartup");
fn build_sysroot_for_triple( fn build_sysroot_for_triple(
dirs: &Dirs, dirs: &Dirs,
@ -285,7 +286,10 @@ fn build_clif_sysroot_for_triple(
fn build_rtstartup(dirs: &Dirs, compiler: &Compiler) -> Option<SysrootTarget> { fn build_rtstartup(dirs: &Dirs, compiler: &Compiler) -> Option<SysrootTarget> {
if !config::get_bool("keep_sysroot") { if !config::get_bool("keep_sysroot") {
crate::prepare::prepare_stdlib(dirs, &compiler.rustc); let sysroot_src_orig = get_default_sysroot(&compiler.rustc).join("lib/rustlib/src/rust");
assert!(sysroot_src_orig.exists());
apply_patches(dirs, "stdlib", &sysroot_src_orig, &STDLIB_SRC.to_path(dirs));
} }
if !compiler.triple.ends_with("windows-gnu") { if !compiler.triple.ends_with("windows-gnu") {

View File

@ -4,9 +4,7 @@ use std::hash::{Hash, Hasher};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::Command; use std::process::Command;
use crate::build_sysroot::STDLIB_SRC;
use crate::path::{Dirs, RelPath}; use crate::path::{Dirs, RelPath};
use crate::rustc_info::get_default_sysroot;
use crate::utils::{ use crate::utils::{
copy_dir_recursively, remove_dir_if_exists, retry_spawn_and_wait, spawn_and_wait, copy_dir_recursively, remove_dir_if_exists, retry_spawn_and_wait, spawn_and_wait,
}; };
@ -17,13 +15,6 @@ pub(crate) fn prepare(dirs: &Dirs) {
crate::tests::REGEX_REPO.fetch(dirs); crate::tests::REGEX_REPO.fetch(dirs);
} }
pub(crate) fn prepare_stdlib(dirs: &Dirs, rustc: &Path) {
let sysroot_src_orig = get_default_sysroot(rustc).join("lib/rustlib/src/rust");
assert!(sysroot_src_orig.exists());
apply_patches(dirs, "stdlib", &sysroot_src_orig, &STDLIB_SRC.to_path(dirs));
}
pub(crate) struct GitRepo { pub(crate) struct GitRepo {
url: GitRepoUrl, url: GitRepoUrl,
rev: &'static str, rev: &'static str,

View File

@ -117,7 +117,7 @@ pub(crate) static RAND_REPO: GitRepo = GitRepo::github(
"rand", "rand",
); );
pub(crate) static RAND: CargoProject = CargoProject::new(&RAND_REPO.source_dir(), "rand_target"); static RAND: CargoProject = CargoProject::new(&RAND_REPO.source_dir(), "rand_target");
pub(crate) static REGEX_REPO: GitRepo = GitRepo::github( pub(crate) static REGEX_REPO: GitRepo = GitRepo::github(
"rust-lang", "rust-lang",
@ -127,12 +127,11 @@ pub(crate) static REGEX_REPO: GitRepo = GitRepo::github(
"regex", "regex",
); );
pub(crate) static REGEX: CargoProject = CargoProject::new(&REGEX_REPO.source_dir(), "regex_target"); static REGEX: CargoProject = CargoProject::new(&REGEX_REPO.source_dir(), "regex_target");
pub(crate) static PORTABLE_SIMD_SRC: RelPath = RelPath::BUILD.join("portable-simd"); static PORTABLE_SIMD_SRC: RelPath = RelPath::BUILD.join("portable-simd");
pub(crate) static PORTABLE_SIMD: CargoProject = static PORTABLE_SIMD: CargoProject = CargoProject::new(&PORTABLE_SIMD_SRC, "portable-simd_target");
CargoProject::new(&PORTABLE_SIMD_SRC, "portable-simd_target");
static LIBCORE_TESTS_SRC: RelPath = RelPath::BUILD.join("coretests"); static LIBCORE_TESTS_SRC: RelPath = RelPath::BUILD.join("coretests");