Skip to content

Commit d78063d

Browse files
committed
rustbuild: Support cross rust-docs packages
Right now if you configure multiple hosts rustbuild will only build documentation for the build triple, but we've got all the support necessary to build documentation for different architectures as well. This commit reinterprets the `target` field of doc `Step` instances to be the target of the documentation rather than the target of the rustdoc/tool being run. This should enable `make dist` to start producing a bunch of `rust-docs` packages for all the cross architectures that rustbuild is producing now.
1 parent 4e75872 commit d78063d

File tree

3 files changed

+46
-35
lines changed

3 files changed

+46
-35
lines changed

src/bootstrap/build/dist.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub fn docs(build: &Build, stage: u32, host: &str) {
5252
.arg(format!("--image-dir={}", sanitize_sh(&image)))
5353
.arg(format!("--work-dir={}", sanitize_sh(&tmpdir(build))))
5454
.arg(format!("--output-dir={}", sanitize_sh(&distdir(build))))
55-
.arg(format!("--package-name={}", name))
55+
.arg(format!("--package-name={}-{}", name, host))
5656
.arg("--component-name=rust-docs")
5757
.arg("--legacy-manifest-dirs=rustlib,cargo")
5858
.arg("--bulk-dirs=share/doc/rust/html");
@@ -61,9 +61,11 @@ pub fn docs(build: &Build, stage: u32, host: &str) {
6161

6262
// As part of this step, *also* copy the docs directory to a directory which
6363
// buildbot typically uploads.
64-
let dst = distdir(build).join("doc").join(&build.package_vers);
65-
t!(fs::create_dir_all(&dst));
66-
cp_r(&src, &dst);
64+
if host == build.config.build {
65+
let dst = distdir(build).join("doc").join(&build.package_vers);
66+
t!(fs::create_dir_all(&dst));
67+
cp_r(&src, &dst);
68+
}
6769
}
6870

6971
pub fn mingw(build: &Build, host: &str) {

src/bootstrap/build/doc.rs

+26-24
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,30 @@ use std::process::Command;
1616
use build::{Build, Compiler, Mode};
1717
use build::util::{up_to_date, cp_r};
1818

19-
pub fn rustbook(build: &Build, stage: u32, host: &str, name: &str, out: &Path) {
19+
pub fn rustbook(build: &Build, stage: u32, target: &str, name: &str, out: &Path) {
2020
t!(fs::create_dir_all(out));
2121

2222
let out = out.join(name);
23-
let compiler = Compiler::new(stage, host);
23+
let compiler = Compiler::new(stage, &build.config.build);
2424
let src = build.src.join("src/doc").join(name);
2525
let index = out.join("index.html");
2626
let rustbook = build.tool(&compiler, "rustbook");
2727
if up_to_date(&src, &index) && up_to_date(&rustbook, &index) {
2828
return
2929
}
30-
println!("Rustbook stage{} ({}) - {}", stage, host, name);
30+
println!("Rustbook stage{} ({}) - {}", stage, target, name);
3131
let _ = fs::remove_dir_all(&out);
3232
build.run(build.tool_cmd(&compiler, "rustbook")
3333
.arg("build")
3434
.arg(&src)
3535
.arg(out));
3636
}
3737

38-
pub fn standalone(build: &Build, stage: u32, host: &str, out: &Path) {
39-
println!("Documenting stage{} standalone ({})", stage, host);
38+
pub fn standalone(build: &Build, stage: u32, target: &str, out: &Path) {
39+
println!("Documenting stage{} standalone ({})", stage, target);
4040
t!(fs::create_dir_all(out));
4141

42-
let compiler = Compiler::new(stage, host);
42+
let compiler = Compiler::new(stage, &build.config.build);
4343

4444
let favicon = build.src.join("src/doc/favicon.inc");
4545
let footer = build.src.join("src/doc/footer.inc");
@@ -105,59 +105,61 @@ pub fn standalone(build: &Build, stage: u32, host: &str, out: &Path) {
105105
}
106106
}
107107

108-
pub fn std(build: &Build, stage: u32, host: &str, out: &Path) {
109-
println!("Documenting stage{} std ({})", stage, host);
110-
let compiler = Compiler::new(stage, host);
108+
pub fn std(build: &Build, stage: u32, target: &str, out: &Path) {
109+
println!("Documenting stage{} std ({})", stage, target);
110+
t!(fs::create_dir_all(out));
111+
let compiler = Compiler::new(stage, &build.config.build);
111112
let out_dir = build.stage_out(&compiler, Mode::Libstd)
112-
.join(host).join("doc");
113+
.join(target).join("doc");
113114
let rustdoc = build.rustdoc(&compiler);
114115

115116
build.clear_if_dirty(&out_dir, &rustdoc);
116117

117-
let mut cargo = build.cargo(&compiler, Mode::Libstd, host, "doc");
118+
let mut cargo = build.cargo(&compiler, Mode::Libstd, target, "doc");
118119
cargo.arg("--manifest-path")
119120
.arg(build.src.join("src/rustc/std_shim/Cargo.toml"))
120121
.arg("--features").arg(build.std_features());
121122
build.run(&mut cargo);
122123
cp_r(&out_dir, out)
123124
}
124125

125-
pub fn test(build: &Build, stage: u32, host: &str, out: &Path) {
126-
println!("Documenting stage{} test ({})", stage, host);
127-
let compiler = Compiler::new(stage, host);
126+
pub fn test(build: &Build, stage: u32, target: &str, out: &Path) {
127+
println!("Documenting stage{} test ({})", stage, target);
128+
let compiler = Compiler::new(stage, &build.config.build);
128129
let out_dir = build.stage_out(&compiler, Mode::Libtest)
129-
.join(host).join("doc");
130+
.join(target).join("doc");
130131
let rustdoc = build.rustdoc(&compiler);
131132

132133
build.clear_if_dirty(&out_dir, &rustdoc);
133134

134-
let mut cargo = build.cargo(&compiler, Mode::Libtest, host, "doc");
135+
let mut cargo = build.cargo(&compiler, Mode::Libtest, target, "doc");
135136
cargo.arg("--manifest-path")
136137
.arg(build.src.join("src/rustc/test_shim/Cargo.toml"));
137138
build.run(&mut cargo);
138139
cp_r(&out_dir, out)
139140
}
140141

141-
pub fn rustc(build: &Build, stage: u32, host: &str, out: &Path) {
142-
println!("Documenting stage{} compiler ({})", stage, host);
143-
let compiler = Compiler::new(stage, host);
142+
pub fn rustc(build: &Build, stage: u32, target: &str, out: &Path) {
143+
println!("Documenting stage{} compiler ({})", stage, target);
144+
let compiler = Compiler::new(stage, &build.config.build);
144145
let out_dir = build.stage_out(&compiler, Mode::Librustc)
145-
.join(host).join("doc");
146+
.join(target).join("doc");
146147
let rustdoc = build.rustdoc(&compiler);
147148
if !up_to_date(&rustdoc, &out_dir.join("rustc/index.html")) {
148149
t!(fs::remove_dir_all(&out_dir));
149150
}
150-
let mut cargo = build.cargo(&compiler, Mode::Librustc, host, "doc");
151+
let mut cargo = build.cargo(&compiler, Mode::Librustc, target, "doc");
151152
cargo.arg("--manifest-path")
152153
.arg(build.src.join("src/rustc/Cargo.toml"))
153154
.arg("--features").arg(build.rustc_features());
154155
build.run(&mut cargo);
155156
cp_r(&out_dir, out)
156157
}
157158

158-
pub fn error_index(build: &Build, stage: u32, host: &str, out: &Path) {
159-
println!("Documenting stage{} error index ({})", stage, host);
160-
let compiler = Compiler::new(stage, host);
159+
pub fn error_index(build: &Build, stage: u32, target: &str, out: &Path) {
160+
println!("Documenting stage{} error index ({})", stage, target);
161+
t!(fs::create_dir_all(out));
162+
let compiler = Compiler::new(stage, &build.config.build);
161163
let mut index = build.tool_cmd(&compiler, "error_index_generator");
162164
index.arg("html");
163165
index.arg(out.join("error-index.html"));

src/bootstrap/build/step.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -274,22 +274,28 @@ impl<'a> Step<'a> {
274274
vec![self.llvm(()).target(&build.config.build)]
275275
}
276276
Source::Llvm { _dummy } => Vec::new(),
277+
278+
// Note that all doc targets depend on artifacts from the build
279+
// architecture, not the target (which is where we're generating
280+
// docs into).
277281
Source::DocStd { stage } => {
278-
vec![self.libstd(self.compiler(stage))]
282+
let compiler = self.target(&build.config.build).compiler(stage);
283+
vec![self.libstd(compiler)]
279284
}
280285
Source::DocTest { stage } => {
281-
vec![self.libtest(self.compiler(stage))]
286+
let compiler = self.target(&build.config.build).compiler(stage);
287+
vec![self.libtest(compiler)]
282288
}
283289
Source::DocBook { stage } |
284290
Source::DocNomicon { stage } |
285291
Source::DocStyle { stage } => {
286-
vec![self.tool_rustbook(stage)]
292+
vec![self.target(&build.config.build).tool_rustbook(stage)]
287293
}
288294
Source::DocErrorIndex { stage } => {
289-
vec![self.tool_error_index(stage)]
295+
vec![self.target(&build.config.build).tool_error_index(stage)]
290296
}
291297
Source::DocStandalone { stage } => {
292-
vec![self.rustc(stage)]
298+
vec![self.target(&build.config.build).rustc(stage)]
293299
}
294300
Source::DocRustc { stage } => {
295301
vec![self.doc_test(stage)]
@@ -333,7 +339,6 @@ impl<'a> Step<'a> {
333339

334340
Source::Dist { stage } => {
335341
let mut base = Vec::new();
336-
base.push(self.dist_docs(stage));
337342

338343
for host in build.config.host.iter() {
339344
let host = self.target(host);
@@ -344,7 +349,9 @@ impl<'a> Step<'a> {
344349

345350
let compiler = self.compiler(stage);
346351
for target in build.config.target.iter() {
347-
base.push(self.target(target).dist_std(compiler));
352+
let target = self.target(target);
353+
base.push(target.dist_docs(stage));
354+
base.push(target.dist_std(compiler));
348355
}
349356
}
350357
return base

0 commit comments

Comments
 (0)