Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,17 +508,30 @@ impl Context {

// Construct the path that contains the documentation inside the tarball.
let tarball_dir = format!("{tarball_prefix}/rustc-docs/share/doc/rust/html");
let tarball_dir_new = format!("{tarball_dir}/rustc");

if Command::new("tar")
.arg("tf")
.arg(&tarball)
.arg(&tarball_dir_new)
.current_dir(&rustc_docs)
.output()?
.status
.success()
{

// NOTE: The following logic is to accommodate 3 different `rustc-docs` structures that
// have existed over time, in the chronological order:
// - No subdirectory: `share/doc/rust/html/...`
// - With `rustc/` subdirectory: `share/doc/rust/html/rustc/...`
// - With `rustc-docs/` subdirectory: `share/doc/rust/html/rustc-docs/...`
let mut tarball_dir_new = None;
for subdir in ["rustc-docs", "rustc"] {
let candidate = format!("{tarball_dir}/{subdir}");
if Command::new("tar")
.arg("tf")
.arg(&tarball)
.arg(&candidate)
.current_dir(&rustc_docs)
.output()?
.status
.success()
{
// The candidate directory exists in the tarball.
tarball_dir_new = Some(candidate);
break;
}
}
if let Some(tarball_dir_new) = tarball_dir_new {
// Unpack the rustc documentation into the new directory.
// // Touch all files as well (see above for why).
run(Command::new("tar")
Expand Down