mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 15:32:06 +00:00
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
This commit is contained in:
commit
d3e9191875
@ -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);
|
||||
|
@ -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")
|
||||
|
36
src/test/run-make/rustdoc-verify-output-files/Makefile
Normal file
36
src/test/run-make/rustdoc-verify-output-files/Makefile
Normal file
@ -0,0 +1,36 @@
|
||||
include ../../run-make-fulldeps/tools.mk
|
||||
|
||||
OUTPUT_DIR := "$(TMPDIR)/rustdoc"
|
||||
TMP_OUTPUT_DIR := "$(TMPDIR)/tmp-rustdoc"
|
||||
|
||||
all:
|
||||
# Generate html docs
|
||||
$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --out-dir $(OUTPUT_DIR)
|
||||
|
||||
# Copy first output for to check if it's exactly same after second compilation
|
||||
cp -R $(OUTPUT_DIR) $(TMP_OUTPUT_DIR)
|
||||
|
||||
# Generate html docs once again on same output
|
||||
$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --out-dir $(OUTPUT_DIR)
|
||||
|
||||
# Check if everything exactly same
|
||||
$(DIFF) -r -q $(OUTPUT_DIR) $(TMP_OUTPUT_DIR)
|
||||
|
||||
# Generate json doc on the same output
|
||||
$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --out-dir $(OUTPUT_DIR) -Z unstable-options --output-format json
|
||||
|
||||
# Check if expected json file is generated
|
||||
[ -e $(OUTPUT_DIR)/foobar.json ]
|
||||
|
||||
# TODO
|
||||
# We should re-generate json doc once again and compare the diff with previously
|
||||
# generated one. Because layout of json docs changes in each compilation, we can't
|
||||
# do that currently.
|
||||
#
|
||||
# See https://github.com/rust-lang/rust/issues/103785#issuecomment-1307425590 for details.
|
||||
|
||||
# remove generated json doc
|
||||
rm $(OUTPUT_DIR)/foobar.json
|
||||
|
||||
# Check if json doc compilation broke any of the html files generated previously
|
||||
$(DIFF) -r -q $(OUTPUT_DIR) $(TMP_OUTPUT_DIR)
|
1
src/test/run-make/rustdoc-verify-output-files/src/lib.rs
Normal file
1
src/test/run-make/rustdoc-verify-output-files/src/lib.rs
Normal file
@ -0,0 +1 @@
|
||||
// nothing to see here
|
Loading…
Reference in New Issue
Block a user