Skip to content

Commit 0c8baa7

Browse files
committed
refactor gating of dist docs
1 parent 8f3844f commit 0c8baa7

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

src/bootstrap/dist.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,21 @@ pub struct Docs {
5151
}
5252

5353
impl Step for Docs {
54-
type Output = Option<GeneratedTarball>;
54+
type Output = GeneratedTarball;
5555
const DEFAULT: bool = true;
5656

5757
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
58-
run.path("src/doc")
58+
let default = run.builder.config.docs;
59+
run.path("src/doc").default_condition(default)
5960
}
6061

6162
fn make_run(run: RunConfig<'_>) {
6263
run.builder.ensure(Docs { host: run.target });
6364
}
6465

6566
/// Builds the `rust-docs` installer component.
66-
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
67+
fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
6768
let host = self.host;
68-
if !builder.config.docs {
69-
return None;
70-
}
7169
builder.default_doc(&[]);
7270

7371
let dest = "share/doc/rust/html";
@@ -76,7 +74,7 @@ impl Step for Docs {
7674
tarball.set_product_name("Rust Documentation");
7775
tarball.add_bulk_dir(&builder.doc_out(host), dest);
7876
tarball.add_file(&builder.src.join("src/doc/robots.txt"), dest, 0o644);
79-
Some(tarball.generate())
77+
tarball.generate()
8078
}
8179
}
8280

@@ -1354,6 +1352,10 @@ impl Step for Extended {
13541352
tarballs.push(builder.ensure(Rustc { compiler: builder.compiler(stage, target) }));
13551353
tarballs.push(builder.ensure(Std { compiler, target }).expect("missing std"));
13561354

1355+
if builder.config.docs {
1356+
tarballs.push(builder.ensure(Docs { host: target }));
1357+
}
1358+
13571359
let cargo_installer = builder.ensure(Cargo { compiler, target });
13581360
let rustfmt_installer = builder.ensure(Rustfmt { compiler, target });
13591361
let rust_demangler_installer = builder.ensure(RustDemangler { compiler, target });
@@ -1365,8 +1367,6 @@ impl Step for Extended {
13651367
let mingw_installer = builder.ensure(Mingw { host: target });
13661368
let analysis_installer = builder.ensure(Analysis { compiler, target });
13671369

1368-
let docs_installer = builder.ensure(Docs { host: target });
1369-
13701370
let etc = builder.src.join("src/etc/installer");
13711371

13721372
// Avoid producing tarballs during a dry run.
@@ -1385,9 +1385,6 @@ impl Step for Extended {
13851385
if let Some(analysis_installer) = analysis_installer {
13861386
tarballs.push(analysis_installer);
13871387
}
1388-
if let Some(docs_installer) = docs_installer {
1389-
tarballs.push(docs_installer);
1390-
}
13911388
if target.contains("pc-windows-gnu") {
13921389
tarballs.push(mingw_installer.unwrap());
13931390
}

src/bootstrap/install.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,8 @@ macro_rules! install {
139139

140140
install!((self, builder, _config),
141141
Docs, "src/doc", _config.docs, only_hosts: false, {
142-
if let Some(tarball) = builder.ensure(dist::Docs { host: self.target }) {
143-
install_sh(builder, "docs", self.compiler.stage, Some(self.target), &tarball);
144-
} else {
145-
panic!("docs are not available to install, \
146-
check that `build.docs` is true in `config.toml`");
147-
}
142+
let tarball = builder.ensure(dist::Docs { host: self.target });
143+
install_sh(builder, "docs", self.compiler.stage, Some(self.target), &tarball);
148144
};
149145
Std, "library/std", true, only_hosts: false, {
150146
for target in &builder.targets {

0 commit comments

Comments
 (0)