Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tokio = "0.1"
systemstat = "0.1.4"
prometheus = { version = "0.7.0", default-features = false }
lazy_static = "1.0.0"
rustwide = "0.4.0"
rustwide = "0.5.0"
tempdir = "0.3"

# iron dependencies
Expand Down
38 changes: 35 additions & 3 deletions src/docbuilder/rustwide_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ use postgres::Connection;
use rustc_serialize::json::ToJson;
use rustwide::cmd::{Command, SandboxBuilder};
use rustwide::logging::{self, LogStorage};
use rustwide::toolchain::ToolchainError;
use rustwide::{Build, Crate, Toolchain, Workspace, WorkspaceBuilder};
use std::borrow::Cow;
use std::collections::HashSet;
use std::path::Path;
use utils::{copy_doc_dir, parse_rustc_version, CargoMetadata};
use Metadata;
Expand All @@ -19,7 +21,6 @@ static USER_AGENT: &str = "docs.rs builder (https://github.com/rust-lang/docs.rs
static DEFAULT_RUSTWIDE_WORKSPACE: &str = ".rustwide";

static TARGETS: &[&str] = &[
"i686-apple-darwin",
"i686-pc-windows-msvc",
"i686-unknown-linux-gnu",
"x86_64-apple-darwin",
Expand Down Expand Up @@ -95,12 +96,43 @@ impl RustwideBuilder {
// Ignore errors if detection fails.
let old_version = self.detect_rustc_version().ok();

let mut targets_to_install = TARGETS
.iter()
.map(|t| t.to_string())
.collect::<HashSet<_>>();
let installed_targets = match self.toolchain.installed_targets(&self.workspace) {
Ok(targets) => targets,
Err(err) => {
if let Some(&ToolchainError::NotInstalled) = err.downcast_ref::<ToolchainError>() {
Vec::new()
} else {
return Err(err);
}
}
};

// The extra targets are intentionally removed *before* trying to update.
//
// If a target is installed locally and it goes missing the next update, rustup will block
// the update to avoid leaving the system in a broken state. This is not a behavior we want
// though when we also remove the target from the list managed by docs.rs: we want that
// target gone, and we don't care if it's missing in the next update.
//
// Removing it beforehand works fine, and prevents rustup from blocking the update later in
// the method.
for target in installed_targets {
if !targets_to_install.remove(&target) {
self.toolchain.remove_target(&self.workspace, &target)?;
}
}

self.toolchain.install(&self.workspace)?;
for target in TARGETS {

for target in &targets_to_install {
self.toolchain.add_target(&self.workspace, target)?;
}
self.rustc_version = self.detect_rustc_version()?;

self.rustc_version = self.detect_rustc_version()?;
if old_version.as_ref().map(|s| s.as_str()) != Some(&self.rustc_version) {
self.add_essential_files()?;
}
Expand Down