Skip to content

Commit bd620c9

Browse files
committed
Update Std doc step
1 parent 2639a3a commit bd620c9

File tree

3 files changed

+40
-27
lines changed

3 files changed

+40
-27
lines changed

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ impl Step for Docs {
9292

9393
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
9494
pub struct JsonDocs {
95-
pub host: TargetSelection,
95+
build_compiler: Compiler,
96+
target: TargetSelection,
9697
}
9798

9899
impl Step for JsonDocs {
@@ -105,24 +106,27 @@ impl Step for JsonDocs {
105106
}
106107

107108
fn make_run(run: RunConfig<'_>) {
108-
run.builder.ensure(JsonDocs { host: run.target });
109+
run.builder.ensure(JsonDocs {
110+
build_compiler: run.builder.compiler(run.builder.top_stage, run.builder.host_target),
111+
target: run.target,
112+
});
109113
}
110114

111115
/// Builds the `rust-docs-json` installer component.
112116
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
113-
let host = self.host;
114-
builder.ensure(crate::core::build_steps::doc::Std::new(
115-
builder.top_stage,
116-
host,
117+
let target = self.target;
118+
builder.ensure(crate::core::build_steps::doc::Std::from_build_compiler(
119+
self.build_compiler,
120+
target,
117121
DocumentationFormat::Json,
118122
));
119123

120124
let dest = "share/doc/rust/json";
121125

122-
let mut tarball = Tarball::new(builder, "rust-docs-json", &host.triple);
126+
let mut tarball = Tarball::new(builder, "rust-docs-json", &target.triple);
123127
tarball.set_product_name("Rust Documentation In JSON Format");
124128
tarball.is_preview(true);
125-
tarball.add_bulk_dir(builder.json_doc_out(host), dest);
129+
tarball.add_bulk_dir(builder.json_doc_out(target), dest);
126130
Some(tarball.generate())
127131
}
128132
}
@@ -1582,7 +1586,7 @@ impl Step for Extended {
15821586
}
15831587

15841588
add_component!("rust-docs" => Docs { host: target });
1585-
add_component!("rust-json-docs" => JsonDocs { host: target });
1589+
add_component!("rust-json-docs" => JsonDocs { build_compiler: compiler, target });
15861590
add_component!("cargo" => Cargo { build_compiler: compiler, target });
15871591
add_component!("rustfmt" => Rustfmt { build_compiler: compiler, target });
15881592
add_component!("rust-analyzer" => RustAnalyzer { build_compiler: compiler, target });

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

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -579,17 +579,22 @@ impl Step for SharedAssets {
579579
}
580580
}
581581

582+
/// Document the standard library using `build_compiler`.
582583
#[derive(Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
583584
pub struct Std {
584-
pub stage: u32,
585-
pub target: TargetSelection,
586-
pub format: DocumentationFormat,
585+
build_compiler: Compiler,
586+
target: TargetSelection,
587+
format: DocumentationFormat,
587588
crates: Vec<String>,
588589
}
589590

590591
impl Std {
591-
pub(crate) fn new(stage: u32, target: TargetSelection, format: DocumentationFormat) -> Self {
592-
Std { stage, target, format, crates: vec![] }
592+
pub(crate) fn from_build_compiler(
593+
build_compiler: Compiler,
594+
target: TargetSelection,
595+
format: DocumentationFormat,
596+
) -> Self {
597+
Std { build_compiler, target, format, crates: vec![] }
593598
}
594599
}
595600

@@ -609,7 +614,7 @@ impl Step for Std {
609614
return;
610615
}
611616
run.builder.ensure(Std {
612-
stage: run.builder.top_stage,
617+
build_compiler: run.builder.compiler(run.builder.top_stage, run.builder.host_target),
613618
target: run.target,
614619
format: if run.builder.config.cmd.json() {
615620
DocumentationFormat::Json
@@ -625,7 +630,6 @@ impl Step for Std {
625630
/// This will generate all documentation for the standard library and its
626631
/// dependencies. This is largely just a wrapper around `cargo doc`.
627632
fn run(self, builder: &Builder<'_>) {
628-
let stage = self.stage;
629633
let target = self.target;
630634
let crates = if self.crates.is_empty() {
631635
builder
@@ -667,7 +671,7 @@ impl Step for Std {
667671
// For `--index-page` and `--output-format=json`.
668672
extra_args.push("-Zunstable-options");
669673

670-
doc_std(builder, self.format, stage, target, &out, &extra_args, &crates);
674+
doc_std(builder, self.format, self.build_compiler, target, &out, &extra_args, &crates);
671675

672676
// Don't open if the format is json
673677
if let DocumentationFormat::Json = self.format {
@@ -692,7 +696,7 @@ impl Step for Std {
692696
fn metadata(&self) -> Option<StepMetadata> {
693697
Some(
694698
StepMetadata::doc("std", self.target)
695-
.stage(self.stage)
699+
.built_by(self.build_compiler)
696700
.with_metadata(format!("crates=[{}]", self.crates.join(","))),
697701
)
698702
}
@@ -728,24 +732,29 @@ impl DocumentationFormat {
728732
fn doc_std(
729733
builder: &Builder<'_>,
730734
format: DocumentationFormat,
731-
stage: u32,
735+
build_compiler: Compiler,
732736
target: TargetSelection,
733737
out: &Path,
734738
extra_args: &[&str],
735739
requested_crates: &[String],
736740
) {
737-
let compiler = builder.compiler(stage, builder.config.host_target);
738-
739741
let target_doc_dir_name = if format == DocumentationFormat::Json { "json-doc" } else { "doc" };
740-
let target_dir = builder.stage_out(compiler, Mode::Std).join(target).join(target_doc_dir_name);
742+
let target_dir =
743+
builder.stage_out(build_compiler, Mode::Std).join(target).join(target_doc_dir_name);
741744

742745
// This is directory where the compiler will place the output of the command.
743746
// We will then copy the files from this directory into the final `out` directory, the specified
744747
// as a function parameter.
745748
let out_dir = target_dir.join(target).join("doc");
746749

747-
let mut cargo =
748-
builder::Cargo::new(builder, compiler, Mode::Std, SourceType::InTree, target, Kind::Doc);
750+
let mut cargo = builder::Cargo::new(
751+
builder,
752+
build_compiler,
753+
Mode::Std,
754+
SourceType::InTree,
755+
target,
756+
Kind::Doc,
757+
);
749758

750759
compile::std_cargo(builder, target, &mut cargo);
751760
cargo
@@ -773,7 +782,7 @@ fn doc_std(
773782

774783
let description =
775784
format!("library{} in {} format", crate_description(requested_crates), format.as_str());
776-
let _guard = builder.msg_doc(compiler, description, target);
785+
let _guard = builder.msg_doc(build_compiler, description, target);
777786

778787
cargo.into_cmd().run(builder);
779788
builder.cp_link_r(&out_dir, out);

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,8 +983,8 @@ impl Step for RustdocJSStd {
983983
command.arg("--test-file").arg(path);
984984
}
985985
}
986-
builder.ensure(crate::core::build_steps::doc::Std::new(
987-
builder.top_stage,
986+
builder.ensure(crate::core::build_steps::doc::Std::from_build_compiler(
987+
builder.compiler(builder.top_stage, builder.host_target),
988988
self.target,
989989
DocumentationFormat::Html,
990990
));

0 commit comments

Comments
 (0)