diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-11-23 20:32:36 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-23 20:32:36 +0530 |
| commit | d3e91918759a44372ea42afd11bbc2644a7883a7 (patch) | |
| tree | ea27227f394b1fbaca403b072720afd4d071b3b2 /src/bootstrap | |
| parent | bd91c94a5d744e0f93aff073bdbb69d0f4e8d9f6 (diff) | |
| parent | 7e28df9561cbfb98c0b5a7f4868823709c1914c1 (diff) | |
| download | rust-d3e91918759a44372ea42afd11bbc2644a7883a7.tar.gz rust-d3e91918759a44372ea42afd11bbc2644a7883a7.zip | |
Rollup merge of #104286 - ozkanonur:fix-doc-bootstrap-recompilation, r=jyn514
copy doc output files by format This pr provides copying doc outputs by checking output format without removing output directory on each trigger. Resolves #103785
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/builder.rs | 8 | ||||
| -rw-r--r-- | src/bootstrap/doc.rs | 21 |
2 files changed, 15 insertions, 14 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 8d999302a6d..251431a15eb 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1094,7 +1094,13 @@ impl<'a> Builder<'a> { let my_out = match mode { // This is the intended out directory for compiler documentation. Mode::Rustc | Mode::ToolRustc => self.compiler_doc_out(target), - Mode::Std => out_dir.join(target.triple).join("doc"), + Mode::Std => { + if self.config.cmd.json() { + out_dir.join(target.triple).join("json-doc") + } else { + out_dir.join(target.triple).join("doc") + } + } _ => panic!("doc mode {:?} not expected", mode), }; let rustdoc = self.rustdoc(compiler); diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 3180a12c85b..571396eb835 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -564,27 +564,22 @@ fn doc_std( ); } let compiler = builder.compiler(stage, builder.config.build); + + let target_doc_dir_name = if format == DocumentationFormat::JSON { "json-doc" } else { "doc" }; + let target_dir = + builder.stage_out(compiler, Mode::Std).join(target.triple).join(target_doc_dir_name); + // This is directory where the compiler will place the output of the command. // We will then copy the files from this directory into the final `out` directory, the specified // as a function parameter. - let out_dir = builder.stage_out(compiler, Mode::Std).join(target.triple).join("doc"); - // `cargo` uses the same directory for both JSON docs and HTML docs. - // This could lead to cross-contamination when copying files into the specified `out` directory. - // For example: - // ```bash - // x doc std - // x doc std --json - // ``` - // could lead to HTML docs being copied into the JSON docs output directory. - // To avoid this issue, we clean the doc folder before invoking `cargo`. - if out_dir.exists() { - builder.remove_dir(&out_dir); - } + let out_dir = target_dir.join(target.triple).join("doc"); let run_cargo_rustdoc_for = |package: &str| { let mut cargo = builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "rustdoc"); compile::std_cargo(builder, target, compiler.stage, &mut cargo); cargo + .arg("--target-dir") + .arg(&*target_dir.to_string_lossy()) .arg("-p") .arg(package) .arg("-Zskip-rustdoc-fingerprint") |
