Skip to content

Commit cdd7437

Browse files
committed
Auto merge of rust-lang#61639 - Mark-Simulacrum:bootstrap-cleanup, r=alexcrichton
Bootstrap cleanup Each commit is (mostly) standalone and probably best reviewed as such. Nothing too major just some drive-by nits as I was looking through the code. r? @alexcrichton
2 parents 0e4a56b + d728d27 commit cdd7437

File tree

5 files changed

+20
-74
lines changed

5 files changed

+20
-74
lines changed

src/bootstrap/builder.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1693,10 +1693,6 @@ mod __test {
16931693
compiler: Compiler { host: a, stage: 1 },
16941694
target: b,
16951695
},
1696-
compile::Std {
1697-
compiler: Compiler { host: a, stage: 2 },
1698-
target: b,
1699-
},
17001696
]
17011697
);
17021698
assert_eq!(

src/bootstrap/doc.rs

+12-39
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ macro_rules! book {
4646
}
4747

4848
fn run(self, builder: &Builder<'_>) {
49-
builder.ensure(Rustbook {
49+
builder.ensure(RustbookSrc {
5050
target: self.target,
5151
name: INTERNER.intern_str($book_name),
5252
version: $book_ver,
53+
src: doc_src(builder),
5354
})
5455
}
5556
}
@@ -75,35 +76,8 @@ enum RustbookVersion {
7576
MdBook2,
7677
}
7778

78-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
79-
struct Rustbook {
80-
target: Interned<String>,
81-
name: Interned<String>,
82-
version: RustbookVersion,
83-
}
84-
85-
impl Step for Rustbook {
86-
type Output = ();
87-
88-
// rustbook is never directly called, and only serves as a shim for the nomicon and the
89-
// reference.
90-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
91-
run.never()
92-
}
93-
94-
/// Invoke `rustbook` for `target` for the doc book `name`.
95-
///
96-
/// This will not actually generate any documentation if the documentation has
97-
/// already been generated.
98-
fn run(self, builder: &Builder<'_>) {
99-
let src = builder.src.join("src/doc");
100-
builder.ensure(RustbookSrc {
101-
target: self.target,
102-
name: self.name,
103-
src: INTERNER.intern_path(src),
104-
version: self.version,
105-
});
106-
}
79+
fn doc_src(builder: &Builder<'_>) -> Interned<PathBuf> {
80+
INTERNER.intern_path(builder.src.join("src/doc"))
10781
}
10882

10983
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
@@ -274,33 +248,37 @@ impl Step for TheBook {
274248
let name = self.name;
275249

276250
// build book
277-
builder.ensure(Rustbook {
251+
builder.ensure(RustbookSrc {
278252
target,
279253
name: INTERNER.intern_string(name.to_string()),
280254
version: RustbookVersion::MdBook2,
255+
src: doc_src(builder),
281256
});
282257

283258
// building older edition redirects
284259

285260
let source_name = format!("{}/first-edition", name);
286-
builder.ensure(Rustbook {
261+
builder.ensure(RustbookSrc {
287262
target,
288263
name: INTERNER.intern_string(source_name),
289264
version: RustbookVersion::MdBook2,
265+
src: doc_src(builder),
290266
});
291267

292268
let source_name = format!("{}/second-edition", name);
293-
builder.ensure(Rustbook {
269+
builder.ensure(RustbookSrc {
294270
target,
295271
name: INTERNER.intern_string(source_name),
296272
version: RustbookVersion::MdBook2,
273+
src: doc_src(builder),
297274
});
298275

299276
let source_name = format!("{}/2018-edition", name);
300-
builder.ensure(Rustbook {
277+
builder.ensure(RustbookSrc {
301278
target,
302279
name: INTERNER.intern_string(source_name),
303280
version: RustbookVersion::MdBook2,
281+
src: doc_src(builder),
304282
});
305283

306284
// build the version info page and CSS
@@ -898,11 +876,6 @@ impl Step for UnstableBookGen {
898876
fn run(self, builder: &Builder<'_>) {
899877
let target = self.target;
900878

901-
builder.ensure(compile::Std {
902-
compiler: builder.compiler(builder.top_stage, builder.config.build),
903-
target,
904-
});
905-
906879
builder.info(&format!("Generating unstable book md files ({})", target));
907880
let out = builder.md_doc_out(target).join("unstable-book");
908881
builder.create_dir(&out);

src/bootstrap/lib.rs

-5
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,9 @@ pub struct Build {
270270
#[derive(Debug)]
271271
struct Crate {
272272
name: Interned<String>,
273-
version: String,
274273
deps: HashSet<Interned<String>>,
275274
id: String,
276275
path: PathBuf,
277-
doc_step: String,
278-
build_step: String,
279-
test_step: String,
280-
bench_step: String,
281276
}
282277

283278
impl Crate {

src/bootstrap/metadata.rs

-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ struct Output {
2020
struct Package {
2121
id: String,
2222
name: String,
23-
version: String,
2423
source: Option<String>,
2524
manifest_path: String,
2625
}
@@ -84,12 +83,7 @@ fn build_krate(features: &str, build: &mut Build, resolves: &mut Vec<ResolveNode
8483
let mut path = PathBuf::from(package.manifest_path);
8584
path.pop();
8685
build.crates.insert(name, Crate {
87-
build_step: format!("build-crate-{}", name),
88-
doc_step: format!("doc-crate-{}", name),
89-
test_step: format!("test-crate-{}", name),
90-
bench_step: format!("bench-crate-{}", name),
9186
name,
92-
version: package.version,
9387
id: package.id,
9488
deps: HashSet::new(),
9589
path,

src/bootstrap/tool.rs

+8-20
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,6 @@ macro_rules! bootstrap_tool {
268268
}
269269

270270
impl Tool {
271-
pub fn get_mode(&self) -> Mode {
272-
Mode::ToolBootstrap
273-
}
274-
275271
/// Whether this tool requires LLVM to run
276272
pub fn uses_llvm_tools(&self) -> bool {
277273
match self {
@@ -659,23 +655,14 @@ impl<'a> Builder<'a> {
659655
pub fn tool_cmd(&self, tool: Tool) -> Command {
660656
let mut cmd = Command::new(self.tool_exe(tool));
661657
let compiler = self.compiler(0, self.config.build);
662-
self.prepare_tool_cmd(compiler, tool, &mut cmd);
663-
cmd
664-
}
665-
666-
/// Prepares the `cmd` provided to be able to run the `compiler` provided.
667-
///
668-
/// Notably this munges the dynamic library lookup path to point to the
669-
/// right location to run `compiler`.
670-
fn prepare_tool_cmd(&self, compiler: Compiler, tool: Tool, cmd: &mut Command) {
671658
let host = &compiler.host;
659+
// Prepares the `cmd` provided to be able to run the `compiler` provided.
660+
//
661+
// Notably this munges the dynamic library lookup path to point to the
662+
// right location to run `compiler`.
672663
let mut lib_paths: Vec<PathBuf> = vec![
673-
if compiler.stage == 0 {
674-
self.build.rustc_snapshot_libdir()
675-
} else {
676-
PathBuf::from(&self.sysroot_libdir(compiler, compiler.host))
677-
},
678-
self.cargo_out(compiler, tool.get_mode(), *host).join("deps"),
664+
self.build.rustc_snapshot_libdir(),
665+
self.cargo_out(compiler, Mode::ToolBootstrap, *host).join("deps"),
679666
];
680667

681668
// On MSVC a tool may invoke a C compiler (e.g., compiletest in run-make
@@ -696,6 +683,7 @@ impl<'a> Builder<'a> {
696683
}
697684
}
698685

699-
add_lib_path(lib_paths, cmd);
686+
add_lib_path(lib_paths, &mut cmd);
687+
cmd
700688
}
701689
}

0 commit comments

Comments
 (0)