Skip to content

Commit

Permalink
try some more things
Browse files Browse the repository at this point in the history
in particular, this stores *all* source docs in the target/{target_name} directory,
rather than trying to special case one or another
  • Loading branch information
jyn514 committed Nov 27, 2021
1 parent 8756ecb commit 2c619f9
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions src/docbuilder/rustwide_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,22 +351,23 @@ impl RustwideBuilder {
if res.result.successful {
if let Some(name) = res.cargo_metadata.root().library_name() {
let host_target = build.host_target_dir();
has_docs = if metadata.proc_macro {
host_target.join("doc").join(name).is_dir()
} else {
host_target
.join("doc")
.join(default_target)
.join(name)
.is_dir()
}
has_docs = host_target
.join(default_target)
.join("doc")
.join(name)
.is_dir();
}
}

let mut algs = HashSet::new();
if has_docs {
debug!("adding documentation for the default target to the database");
self.copy_docs(&build.host_target_dir(), local_storage.path(), "", true)?;
self.copy_docs(
&build.host_target_dir(),
local_storage.path(),
default_target,
true,
)?;

successful_targets.push(res.target.clone());

Expand Down Expand Up @@ -607,11 +608,15 @@ impl RustwideBuilder {
// However, if this is the default build, we don't want it there,
// we want it in `target/doc`.
// NOTE: don't rename this if the build failed, because `target/<target>/doc` won't exist.
if successful && target != HOST_TARGET && is_default_target {
// mv target/$target/doc target/doc
if successful && metadata.proc_macro {
assert!(
is_default_target && target == HOST_TARGET,
"can't handle cross-compiling macros"
);
// mv target/doc target/$target/doc
let target_dir = build.host_target_dir();
let old_dir = target_dir.join(target).join("doc");
let new_dir = target_dir.join("doc");
let old_dir = target_dir.join("doc");
let new_dir = target_dir.join(target).join("doc");
debug!("rename {} to {}", old_dir.display(), new_dir.display());
std::fs::rename(old_dir, new_dir)?;
}
Expand Down Expand Up @@ -853,11 +858,11 @@ mod tests {

// doc archive exists
let doc_archive = rustdoc_archive_path(crate_, version);
assert!(storage.exists(&doc_archive)?);
assert!(storage.exists(&doc_archive)?, "{}", doc_archive);

// source archive exists
let source_archive = source_archive_path(crate_, version);
assert!(storage.exists(&source_archive)?);
assert!(storage.exists(&source_archive)?, "{}", source_archive);

// default target was built and is accessible
assert!(storage.exists_in_archive(&doc_archive, &format!("{}/index.html", crate_path))?);
Expand Down Expand Up @@ -990,11 +995,11 @@ mod tests {

// doc archive exists
let doc_archive = rustdoc_archive_path(crate_, version);
assert!(storage.exists(&doc_archive)?);
assert!(storage.exists(&doc_archive)?, "{}", doc_archive);

// source archive exists
let source_archive = source_archive_path(crate_, version);
assert!(storage.exists(&source_archive)?);
assert!(storage.exists(&source_archive)?, "{}", source_archive);

let target = "x86_64-unknown-linux-gnu";
let crate_path = crate_.replace("-", "_");
Expand Down

0 comments on commit 2c619f9

Please sign in to comment.