X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fbootstrap%2Fdoc.rs;h=2c6fd1e1d4dd4e19edd1a10c3f9b09bd9afec634;hb=8681d4cffcd23bbe619984ab62772a91827a40dc;hp=3180a12c85be759984d013d5a5907127a4e0e373;hpb=aea4c0c1b8de16e8fbe035ab71593e8939b8d9f7;p=rust.git diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 3180a12c85b..2c6fd1e1d4d 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -458,7 +458,9 @@ fn run(self, builder: &Builder<'_>) { t!(fs::create_dir_all(&out)); - builder.ensure(SharedAssets { target: self.target }); + if self.format == DocumentationFormat::HTML { + builder.ensure(SharedAssets { target: self.target }); + } let index_page = builder.src.join("src/doc/index.md").into_os_string(); let mut extra_args = match self.format { @@ -564,27 +566,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")