Skip to content

Commit a755b4d

Browse files
committed
fix(main)!: change dist path for rustc-docs
1 parent 44a5f66 commit a755b4d

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

src/main.rs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -508,17 +508,30 @@ impl Context {
508508

509509
// Construct the path that contains the documentation inside the tarball.
510510
let tarball_dir = format!("{tarball_prefix}/rustc-docs/share/doc/rust/html");
511-
let tarball_dir_new = format!("{tarball_dir}/rustc");
512-
513-
if Command::new("tar")
514-
.arg("tf")
515-
.arg(&tarball)
516-
.arg(&tarball_dir_new)
517-
.current_dir(&rustc_docs)
518-
.output()?
519-
.status
520-
.success()
521-
{
511+
512+
// NOTE: The following logic is to accommodate 3 different `rustc-docs` structures that
513+
// have existed over time, in the chronological order:
514+
// - No subdirectory: `share/doc/rust/html/...`
515+
// - With `rustc/` subdirectory: `share/doc/rust/html/rustc/...`
516+
// - With `rustc-docs/` subdirectory: `share/doc/rust/html/rustc-docs/...`
517+
let mut tarball_dir_new = None;
518+
for subdir in ["rustc-docs", "rustc"] {
519+
let candidate = format!("{tarball_dir}/{subdir}");
520+
if Command::new("tar")
521+
.arg("tf")
522+
.arg(&tarball)
523+
.arg(&candidate)
524+
.current_dir(&rustc_docs)
525+
.output()?
526+
.status
527+
.success()
528+
{
529+
// The candidate directory exists in the tarball.
530+
tarball_dir_new = Some(candidate);
531+
break;
532+
}
533+
}
534+
if let Some(tarball_dir_new) = tarball_dir_new {
522535
// Unpack the rustc documentation into the new directory.
523536
// // Touch all files as well (see above for why).
524537
run(Command::new("tar")

0 commit comments

Comments
 (0)