Skip to content

Commit d72b282

Browse files
committed
move bootstrap core implementation to bootstrap/src/core module
Signed-off-by: onur-ozkan <[email protected]>
1 parent ef33714 commit d72b282

24 files changed

+790
-189
lines changed

src/bootstrap/check.rs renamed to src/bootstrap/src/core/build_steps/check.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
//! Implementation of compiling the compiler and standard library, in "check"-based modes.
22
3-
use crate::builder::{crate_description, Alias, Builder, Kind, RunConfig, ShouldRun, Step};
4-
use crate::cache::Interned;
5-
use crate::compile::{add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo};
6-
use crate::config::TargetSelection;
7-
use crate::tool::{prepare_tool_cargo, SourceType};
3+
use crate::core::build_steps::compile::{
4+
add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo,
5+
};
6+
use crate::core::build_steps::tool::{prepare_tool_cargo, SourceType};
7+
use crate::core::builder::{crate_description, Alias, Builder, Kind, RunConfig, ShouldRun, Step};
8+
use crate::core::config::TargetSelection;
9+
use crate::utils::cache::Interned;
810
use crate::INTERNER;
911
use crate::{Compiler, Mode, Subcommand};
1012
use std::path::{Path, PathBuf};
@@ -16,7 +18,7 @@ pub struct Std {
1618
///
1719
/// This shouldn't be used from other steps; see the comment on [`compile::Rustc`].
1820
///
19-
/// [`compile::Rustc`]: crate::compile::Rustc
21+
/// [`compile::Rustc`]: crate::core::build_steps::compile::Rustc
2022
crates: Interned<Vec<String>>,
2123
}
2224

@@ -193,7 +195,7 @@ pub struct Rustc {
193195
///
194196
/// This shouldn't be used from other steps; see the comment on [`compile::Rustc`].
195197
///
196-
/// [`compile::Rustc`]: crate::compile::Rustc
198+
/// [`compile::Rustc`]: crate::core::build_steps::compile::Rustc
197199
crates: Interned<Vec<String>>,
198200
}
199201

@@ -237,8 +239,8 @@ impl Step for Rustc {
237239
// the sysroot for the compiler to find. Otherwise, we're going to
238240
// fail when building crates that need to generate code (e.g., build
239241
// scripts and their dependencies).
240-
builder.ensure(crate::compile::Std::new(compiler, compiler.host));
241-
builder.ensure(crate::compile::Std::new(compiler, target));
242+
builder.ensure(crate::core::build_steps::compile::Std::new(compiler, compiler.host));
243+
builder.ensure(crate::core::build_steps::compile::Std::new(compiler, target));
242244
} else {
243245
builder.ensure(Std::new(target));
244246
}
@@ -387,7 +389,7 @@ impl Step for RustAnalyzer {
387389
&["rust-analyzer/in-rust-tree".to_owned()],
388390
);
389391

390-
cargo.allow_features(crate::tool::RustAnalyzer::ALLOW_FEATURES);
392+
cargo.allow_features(crate::core::build_steps::tool::RustAnalyzer::ALLOW_FEATURES);
391393

392394
// For ./x.py clippy, don't check those targets because
393395
// linting tests and benchmarks can produce very noisy results

src/bootstrap/clean.rs renamed to src/bootstrap/src/core/build_steps/clean.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use std::fs;
99
use std::io::{self, ErrorKind};
1010
use std::path::Path;
1111

12-
use crate::builder::{crate_description, Builder, RunConfig, ShouldRun, Step};
13-
use crate::cache::Interned;
14-
use crate::util::t;
12+
use crate::core::builder::{crate_description, Builder, RunConfig, ShouldRun, Step};
13+
use crate::utils::cache::Interned;
14+
use crate::utils::helpers::t;
1515
use crate::{Build, Compiler, Mode, Subcommand};
1616

1717
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]

src/bootstrap/compile.rs renamed to src/bootstrap/src/core/build_steps/compile.rs

+15-13
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@ use std::str;
1919

2020
use serde_derive::Deserialize;
2121

22-
use crate::builder::crate_description;
23-
use crate::builder::Cargo;
24-
use crate::builder::{Builder, Kind, PathSet, RunConfig, ShouldRun, Step, TaskPath};
25-
use crate::cache::{Interned, INTERNER};
26-
use crate::config::{DebuginfoLevel, LlvmLibunwind, RustcLto, TargetSelection};
27-
use crate::dist;
28-
use crate::llvm;
29-
use crate::tool::SourceType;
30-
use crate::util::get_clang_cl_resource_dir;
31-
use crate::util::{exe, is_debug_info, is_dylib, output, symlink_dir, t, up_to_date};
22+
use crate::core::build_steps::dist;
23+
use crate::core::build_steps::llvm;
24+
use crate::core::build_steps::tool::SourceType;
25+
use crate::core::builder::crate_description;
26+
use crate::core::builder::Cargo;
27+
use crate::core::builder::{Builder, Kind, PathSet, RunConfig, ShouldRun, Step, TaskPath};
28+
use crate::core::config::{DebuginfoLevel, LlvmLibunwind, RustcLto, TargetSelection};
29+
use crate::utils::cache::{Interned, INTERNER};
30+
use crate::utils::helpers::{
31+
exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, output, symlink_dir, t, up_to_date,
32+
};
3233
use crate::LLVM_TOOLS;
3334
use crate::{CLang, Compiler, DependencyType, GitRepo, Mode};
3435
use filetime::FileTime;
@@ -510,7 +511,7 @@ impl Step for StdLink {
510511
let (libdir, hostdir) = if self.force_recompile && builder.download_rustc() {
511512
// NOTE: copies part of `sysroot_libdir` to avoid having to add a new `force_recompile` argument there too
512513
let lib = builder.sysroot_libdir_relative(self.compiler);
513-
let sysroot = builder.ensure(crate::compile::Sysroot {
514+
let sysroot = builder.ensure(crate::core::build_steps::compile::Sysroot {
514515
compiler: self.compiler,
515516
force_recompile: self.force_recompile,
516517
});
@@ -1011,7 +1012,8 @@ pub fn rustc_cargo_env(
10111012
// detected that LLVM is already built and good to go which helps prevent
10121013
// busting caches (e.g. like #71152).
10131014
if builder.config.llvm_enabled() {
1014-
let building_is_expensive = crate::llvm::prebuilt_llvm_config(builder, target).is_err();
1015+
let building_is_expensive =
1016+
crate::core::build_steps::llvm::prebuilt_llvm_config(builder, target).is_err();
10151017
// `top_stage == stage` might be false for `check --stage 1`, if we are building the stage 1 compiler
10161018
let can_skip_build = builder.kind == Kind::Check && builder.top_stage == stage;
10171019
let should_skip_build = building_is_expensive && can_skip_build;
@@ -1679,7 +1681,7 @@ impl Step for Assemble {
16791681
builder.copy(&lld_install.join("bin").join(&src_exe), &libdir_bin.join(&dst_exe));
16801682
let self_contained_lld_dir = libdir_bin.join("gcc-ld");
16811683
t!(fs::create_dir(&self_contained_lld_dir));
1682-
let lld_wrapper_exe = builder.ensure(crate::tool::LldWrapper {
1684+
let lld_wrapper_exe = builder.ensure(crate::core::build_steps::tool::LldWrapper {
16831685
compiler: build_compiler,
16841686
target: target_compiler.host,
16851687
});

src/bootstrap/dist.rs renamed to src/bootstrap/src/core/build_steps/dist.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ use std::process::Command;
1919
use object::read::archive::ArchiveFile;
2020
use object::BinaryFormat;
2121

22-
use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
23-
use crate::cache::{Interned, INTERNER};
24-
use crate::channel;
25-
use crate::compile;
26-
use crate::config::TargetSelection;
27-
use crate::doc::DocumentationFormat;
28-
use crate::llvm;
29-
use crate::tarball::{GeneratedTarball, OverlayKind, Tarball};
30-
use crate::tool::{self, Tool};
31-
use crate::util::{exe, is_dylib, output, t, timeit};
22+
use crate::core::build_steps::compile;
23+
use crate::core::build_steps::doc::DocumentationFormat;
24+
use crate::core::build_steps::llvm;
25+
use crate::core::build_steps::tool::{self, Tool};
26+
use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
27+
use crate::core::config::TargetSelection;
28+
use crate::utils::cache::{Interned, INTERNER};
29+
use crate::utils::channel;
30+
use crate::utils::helpers::{exe, is_dylib, output, t, timeit};
31+
use crate::utils::tarball::{GeneratedTarball, OverlayKind, Tarball};
3232
use crate::{Compiler, DependencyType, Mode, LLVM_TOOLS};
3333

3434
pub fn pkgname(builder: &Builder<'_>, component: &str) -> String {
@@ -104,7 +104,7 @@ impl Step for JsonDocs {
104104
/// Builds the `rust-docs-json` installer component.
105105
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
106106
let host = self.host;
107-
builder.ensure(crate::doc::Std::new(
107+
builder.ensure(crate::core::build_steps::doc::Std::new(
108108
builder.top_stage,
109109
host,
110110
builder,
@@ -488,7 +488,7 @@ impl Step for Rustc {
488488
let man_src = builder.src.join("src/doc/man");
489489
let man_dst = image.join("share/man/man1");
490490

491-
// don't use our `bootstrap::util::{copy, cp_r}`, because those try
491+
// don't use our `bootstrap::{copy, cp_r}`, because those try
492492
// to hardlink, and we don't want to edit the source templates
493493
for file_entry in builder.read_dir(&man_src) {
494494
let page_src = file_entry.path();
@@ -2056,7 +2056,7 @@ impl Step for LlvmTools {
20562056
}
20572057
}
20582058

2059-
builder.ensure(crate::llvm::Llvm { target });
2059+
builder.ensure(crate::core::build_steps::llvm::Llvm { target });
20602060

20612061
let mut tarball = Tarball::new(builder, "llvm-tools", &target.triple);
20622062
tarball.set_overlay(OverlayKind::LLVM);
@@ -2115,10 +2115,10 @@ impl Step for RustDev {
21152115
let mut tarball = Tarball::new(builder, "rust-dev", &target.triple);
21162116
tarball.set_overlay(OverlayKind::LLVM);
21172117

2118-
builder.ensure(crate::llvm::Llvm { target });
2118+
builder.ensure(crate::core::build_steps::llvm::Llvm { target });
21192119

21202120
// We want to package `lld` to use it with `download-ci-llvm`.
2121-
builder.ensure(crate::llvm::Lld { target });
2121+
builder.ensure(crate::core::build_steps::llvm::Lld { target });
21222122

21232123
let src_bindir = builder.llvm_out(target).join("bin");
21242124
// If updating this list, you likely want to change

src/bootstrap/doc.rs renamed to src/bootstrap/src/core/build_steps/doc.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
use std::fs;
1111
use std::path::{Path, PathBuf};
1212

13-
use crate::builder::crate_description;
14-
use crate::builder::{Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
15-
use crate::cache::{Interned, INTERNER};
16-
use crate::compile;
17-
use crate::config::{Config, TargetSelection};
18-
use crate::tool::{self, prepare_tool_cargo, SourceType, Tool};
19-
use crate::util::{dir_is_empty, symlink_dir, t, up_to_date};
13+
use crate::core::build_steps::compile;
14+
use crate::core::build_steps::tool::{self, prepare_tool_cargo, SourceType, Tool};
15+
use crate::core::builder::crate_description;
16+
use crate::core::builder::{Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
17+
use crate::core::config::{Config, TargetSelection};
18+
use crate::utils::cache::{Interned, INTERNER};
19+
use crate::utils::helpers::{dir_is_empty, symlink_dir, t, up_to_date};
2020
use crate::Mode;
2121

2222
macro_rules! submodule_helper {

src/bootstrap/format.rs renamed to src/bootstrap/src/core/build_steps/format.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Runs rustfmt on the repository.
22
3-
use crate::builder::Builder;
4-
use crate::util::{output, program_out_of_date, t};
3+
use crate::core::builder::Builder;
4+
use crate::utils::helpers::{output, program_out_of_date, t};
55
use build_helper::ci::CiEnv;
66
use build_helper::git::get_git_modified_files;
77
use ignore::WalkBuilder;

src/bootstrap/install.rs renamed to src/bootstrap/src/core/build_steps/install.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ use std::fs;
88
use std::path::{Component, Path, PathBuf};
99
use std::process::Command;
1010

11-
use crate::util::t;
12-
13-
use crate::dist;
14-
use crate::tarball::GeneratedTarball;
11+
use crate::core::build_steps::dist;
12+
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
13+
use crate::core::config::{Config, TargetSelection};
14+
use crate::utils::helpers::t;
15+
use crate::utils::tarball::GeneratedTarball;
1516
use crate::{Compiler, Kind};
1617

17-
use crate::builder::{Builder, RunConfig, ShouldRun, Step};
18-
use crate::config::{Config, TargetSelection};
19-
2018
#[cfg(target_os = "illumos")]
2119
const SHELL: &str = "bash";
2220
#[cfg(not(target_os = "illumos"))]

src/bootstrap/llvm.rs renamed to src/bootstrap/src/core/build_steps/llvm.rs

+15-12
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ use std::io;
1616
use std::path::{Path, PathBuf};
1717
use std::process::Command;
1818

19-
use crate::builder::{Builder, RunConfig, ShouldRun, Step};
20-
use crate::channel;
21-
use crate::config::{Config, TargetSelection};
22-
use crate::util::get_clang_cl_resource_dir;
23-
use crate::util::{self, exe, output, t, up_to_date};
19+
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
20+
use crate::core::config::{Config, TargetSelection};
21+
use crate::utils::channel;
22+
use crate::utils::helpers::{self, exe, get_clang_cl_resource_dir, output, t, up_to_date};
2423
use crate::{CLang, GitRepo, Kind};
2524

2625
use build_helper::ci::CiEnv;
@@ -281,7 +280,7 @@ impl Step for Llvm {
281280

282281
let _guard = builder.msg_unstaged(Kind::Build, "LLVM", target);
283282
t!(stamp.remove());
284-
let _time = util::timeit(&builder);
283+
let _time = helpers::timeit(&builder);
285284
t!(fs::create_dir_all(&out_dir));
286285

287286
// https://llvm.org/docs/CMake.html
@@ -410,7 +409,7 @@ impl Step for Llvm {
410409

411410
let mut enabled_llvm_projects = Vec::new();
412411

413-
if util::forcing_clang_based_tests() {
412+
if helpers::forcing_clang_based_tests() {
414413
enabled_llvm_projects.push("clang");
415414
enabled_llvm_projects.push("compiler-rt");
416415
}
@@ -528,8 +527,12 @@ impl Step for Llvm {
528527

529528
// If the shared library exists in LLVM's `/build/lib/` or `/lib/` folders, strip its
530529
// debuginfo.
531-
crate::compile::strip_debug(builder, target, &out_dir.join("lib").join(&lib_name));
532-
crate::compile::strip_debug(
530+
crate::core::build_steps::compile::strip_debug(
531+
builder,
532+
target,
533+
&out_dir.join("lib").join(&lib_name),
534+
);
535+
crate::core::build_steps::compile::strip_debug(
533536
builder,
534537
target,
535538
&out_dir.join("build").join("lib").join(&lib_name),
@@ -846,7 +849,7 @@ impl Step for Lld {
846849
}
847850

848851
let _guard = builder.msg_unstaged(Kind::Build, "LLD", target);
849-
let _time = util::timeit(&builder);
852+
let _time = helpers::timeit(&builder);
850853
t!(fs::create_dir_all(&out_dir));
851854

852855
let mut cfg = cmake::Config::new(builder.src.join("src/llvm-project/lld"));
@@ -877,7 +880,7 @@ impl Step for Lld {
877880
// `LD_LIBRARY_PATH` overrides)
878881
//
879882
if builder.config.rpath_enabled(target)
880-
&& util::use_host_linker(target)
883+
&& helpers::use_host_linker(target)
881884
&& builder.config.llvm_link_shared()
882885
&& target.contains("linux")
883886
{
@@ -970,7 +973,7 @@ impl Step for Sanitizers {
970973

971974
let _guard = builder.msg_unstaged(Kind::Build, "sanitizers", self.target);
972975
t!(stamp.remove());
973-
let _time = util::timeit(&builder);
976+
let _time = helpers::timeit(&builder);
974977

975978
let mut cfg = cmake::Config::new(&compiler_rt_dir);
976979
cfg.profile("Release");
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
pub(crate) mod check;
2+
pub(crate) mod clean;
3+
pub(crate) mod compile;
4+
pub(crate) mod dist;
5+
pub(crate) mod doc;
6+
pub(crate) mod format;
7+
pub(crate) mod install;
8+
pub(crate) mod llvm;
9+
pub(crate) mod run;
10+
pub(crate) mod setup;
11+
pub(crate) mod suggest;
12+
pub(crate) mod synthetic_targets;
13+
pub(crate) mod test;
14+
pub(crate) mod tool;
15+
pub(crate) mod toolstate;

src/bootstrap/run.rs renamed to src/bootstrap/src/core/build_steps/run.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ use std::process::Command;
33

44
use clap_complete::shells;
55

6-
use crate::builder::{Builder, RunConfig, ShouldRun, Step};
7-
use crate::config::TargetSelection;
8-
use crate::dist::distdir;
9-
use crate::flags::get_completion;
10-
use crate::test;
11-
use crate::tool::{self, SourceType, Tool};
12-
use crate::util::output;
6+
use crate::core::build_steps::dist::distdir;
7+
use crate::core::build_steps::test;
8+
use crate::core::build_steps::tool::{self, SourceType, Tool};
9+
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
10+
use crate::core::config::flags::get_completion;
11+
use crate::core::config::TargetSelection;
12+
use crate::utils::helpers::output;
1313
use crate::Mode;
1414

1515
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]

src/bootstrap/setup.rs renamed to src/bootstrap/src/core/build_steps/setup.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::builder::{Builder, RunConfig, ShouldRun, Step};
1+
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
22
use crate::Config;
33
use crate::{t, CONFIG_CHANGE_HISTORY};
44
use sha2::Digest;
@@ -12,6 +12,7 @@ use std::str::FromStr;
1212
use std::{fmt, fs, io};
1313

1414
#[cfg(test)]
15+
#[path = "../../tests/setup.rs"]
1516
mod tests;
1617

1718
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
@@ -35,7 +36,7 @@ static SETTINGS_HASHES: &[&str] = &[
3536
"47d227f424bf889b0d899b9cc992d5695e1b78c406e183cd78eafefbe5488923",
3637
"b526bd58d0262dd4dda2bff5bc5515b705fb668a46235ace3e057f807963a11a",
3738
];
38-
static RUST_ANALYZER_SETTINGS: &str = include_str!("../etc/rust_analyzer_settings.json");
39+
static RUST_ANALYZER_SETTINGS: &str = include_str!("../../../../etc/rust_analyzer_settings.json");
3940

4041
impl Profile {
4142
fn include_path(&self, src_path: &Path) -> PathBuf {

0 commit comments

Comments
 (0)