Skip to content

Commit 7dd79c5

Browse files
committed
Don't move every build into target/doc
Only the default build should be in target/doc.
1 parent ae14be3 commit 7dd79c5

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/docbuilder/rustwide_builder.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ impl RustwideBuilder {
415415
let cargo_metadata =
416416
CargoMetadata::load(&self.workspace, &self.toolchain, &build.host_source_dir())?;
417417

418+
let is_default_target = target.is_none();
418419
let target = target.or_else(|| metadata.default_target.as_ref().map(|s| s.as_str()));
419420

420421
let mut rustdoc_flags: Vec<String> = vec![
@@ -474,13 +475,19 @@ impl RustwideBuilder {
474475
.run()
475476
.is_ok()
476477
});
478+
// If we're passed a default_target which requires a cross-compile,
479+
// cargo will put the output in `target/<target>/doc`.
480+
// However, if this is the default build, we don't want it there,
481+
// we want it in `target/doc`.
477482
if let Some(explicit_target) = target {
478-
// mv target/$explicit_target/doc target/doc
479-
let target_dir = build.host_target_dir();
480-
let old_dir = target_dir.join(explicit_target).join("doc");
481-
let new_dir = target_dir.join("doc");
482-
debug!("rename {} to {}", old_dir.display(), new_dir.display());
483-
std::fs::rename(old_dir, new_dir)?;
483+
if is_default_target {
484+
// mv target/$explicit_target/doc target/doc
485+
let target_dir = build.host_target_dir();
486+
let old_dir = target_dir.join(explicit_target).join("doc");
487+
let new_dir = target_dir.join("doc");
488+
debug!("rename {} to {}", old_dir.display(), new_dir.display());
489+
std::fs::rename(old_dir, new_dir)?;
490+
}
484491
}
485492

486493
Ok(FullBuildResult {

0 commit comments

Comments
 (0)