Skip to content

Commit

Permalink
Merge branch 'master' into db-bump-version
Browse files Browse the repository at this point in the history
# Conflicts:
#	Cargo.lock
  • Loading branch information
Diggsey committed Jul 7, 2018
2 parents 1086892 + a675b7e commit cd0074b
Show file tree
Hide file tree
Showing 13 changed files with 874 additions and 485 deletions.
1,137 changes: 683 additions & 454 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ rustup-dist = { path = "src/rustup-dist" }
rustup-utils = { path = "src/rustup-utils" }
download = { path = "src/download" }
clap = "2.18.0"
error-chain = "0.11"
error-chain = "0.12.0"
itertools = "0.7.6"
libc = "0.2.0"
markdown = "0.2"
rand = "0.4.2"
regex = "0.2"
remove_dir_all = "0.3.0"
rand = "0.5.2"
regex = "1.0.1"
remove_dir_all = "0.5.1"
same-file = "1.0"
scopeguard = "0.3"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
sha2 = "0.7.0"
tempdir = "0.3.4"
tempfile = "2.1.4"
tempfile = "3.0.2"
term = "0.5.1"
time = "0.1.34"
toml = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion src/download/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ curl-backend = ["curl"]
reqwest-backend = ["reqwest", "env_proxy", "lazy_static"]

[dependencies]
error-chain = "0.11"
error-chain = "0.12"
url = "1.2"
curl = { version = "0.4.6", optional = true }
env_proxy = { version = "0.2.0", optional = true }
Expand Down
9 changes: 9 additions & 0 deletions src/rustup-cli/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ pub static SHOW_HELP: &'static str = r"DISCUSSION:
If there are multiple toolchains installed then all installed
toolchains are listed as well.";

pub static SHOW_ACTIVE_TOOLCHAIN_HELP: &'static str = r"DISCUSSION:
Shows the name of the active toolchain.
This is useful for figuring out the active tool chain from
scripts.
You should use `rustc --print sysroot` to get the sysroot, or
`rustc --version` to get the toolchain version.";

pub static UPDATE_HELP: &'static str = r"DISCUSSION:
With no toolchain specified, the `update` command updates each of
the installed toolchains from the official release channels, then
Expand Down
40 changes: 37 additions & 3 deletions src/rustup-cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ pub fn main() -> Result<()> {
cfg.check_metadata_version()?;

match matches.subcommand() {
("show", Some(_)) => show(cfg)?,
("show", Some(c)) => match c.subcommand() {
("active-toolchain", Some(_)) => show_active_toolchain(cfg)?,
(_, _) => show(cfg)?
},
("install", Some(m)) => update(cfg, m)?,
("update", Some(m)) => update(cfg, m)?,
("uninstall", Some(m)) => toolchain_remove(cfg, m)?,
Expand Down Expand Up @@ -110,7 +113,13 @@ pub fn cli() -> App<'static, 'static> {
.subcommand(
SubCommand::with_name("show")
.about("Show the active and installed toolchains")
.after_help(SHOW_HELP),
.after_help(SHOW_HELP)
.setting(AppSettings::VersionlessSubcommands)
.setting(AppSettings::DeriveDisplayOrder)
.subcommand(SubCommand::with_name("active-toolchain")
.about("Show the active toolchain")
.after_help(SHOW_ACTIVE_TOOLCHAIN_HELP)
),
)
.subcommand(
SubCommand::with_name("install")
Expand Down Expand Up @@ -360,6 +369,11 @@ pub fn cli() -> App<'static, 'static> {
.alias("docs")
.about("Open the documentation for the current toolchain")
.after_help(DOC_HELP)
.arg(
Arg::with_name("path")
.long("path")
.help("Only print the path to the documentation"),
)
.arg(
Arg::with_name("book")
.long("book")
Expand Down Expand Up @@ -733,6 +747,19 @@ fn show(cfg: &Cfg) -> Result<()> {
Ok(())
}

fn show_active_toolchain(cfg: &Cfg) -> Result<()> {
let ref cwd = utils::current_dir()?;
match cfg.find_override_toolchain_or_default(cwd)? {
Some((ref toolchain, _)) => {
println!("{}", toolchain.name());
},
None => {
// Print nothing
}
}
Ok(())
}

fn target_list(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
let toolchain = explicit_or_dir_toolchain(cfg, m)?;

Expand Down Expand Up @@ -929,7 +956,14 @@ fn doc(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
"index.html"
};

Ok(cfg.open_docs_for_dir(&utils::current_dir()?, doc_url)?)
let cwd = &utils::current_dir()?;
if m.is_present("path") {
let doc_path = try!(cfg.doc_path_for_dir(cwd, doc_url));
println!("{}", doc_path.display());
Ok(())
} else {
Ok(cfg.open_docs_for_dir(cwd, doc_url)?)
}
}

fn man(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
Expand Down
7 changes: 3 additions & 4 deletions src/rustup-dist/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repository = "https://github.com/rust-lang-nursery/rustup.rs"
license = "MIT OR Apache-2.0"

[dependencies]
regex = "0.2.0"
regex = "1.0.1"
itertools = "0.7"
ole32-sys = "0.2.0"
url = "1.1.0"
Expand All @@ -23,9 +23,9 @@ xz2 = "0.1.3"
walkdir = "2.0"
toml = "0.4"
sha2 = "0.7.0"
remove_dir_all = "0.3"
remove_dir_all = "0.5.1"
rustup-utils = { path = "../rustup-utils" }
error-chain = "0.11"
error-chain = "0.12"

[dev-dependencies]
rustup-mock = { path = "../rustup-mock" }
Expand All @@ -40,4 +40,3 @@ libc = "0.2.0"

[lib]
name = "rustup_dist"

1 change: 0 additions & 1 deletion src/rustup-mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ wait-timeout = "0.1.3"
[target."cfg(windows)".dependencies]
winapi = "0.3"
winreg = "0.5.0"

8 changes: 4 additions & 4 deletions src/rustup-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ license = "MIT OR Apache-2.0"

[dependencies]
download = { path = "../download" }
error-chain = "0.11"
error-chain = "0.12"
libc = "0.2.0"
rand = "0.4.2"
remove_dir_all = "0.3.0"
rand = "0.5.2"
remove_dir_all = "0.5.1"
scopeguard = "0.3.0"
semver = "0.9.0"
sha2 = "0.7.0"
toml = "0.4"
url = "1.1"

[target."cfg(windows)".dependencies]
winapi = { version = "0.3", features = ["combaseapi", "errhandlingapi", "fileapi", "handleapi",
winapi = { version = "0.3", features = ["combaseapi", "errhandlingapi", "fileapi", "handleapi",
"ioapiset", "minwindef", "processthreadsapi", "shlobj", "shtypes", "userenv", "winbase", "winerror", "winnt", "winioctl"] }
winreg = "0.5.0"
2 changes: 1 addition & 1 deletion src/rustup/telemetry_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl TelemetryAnalysis {
self.rustc_error_statistics.error_codes_with_counts = error_codes_with_counts;
self.rustc_success_statistics = compute_rustc_percentiles(&rustc_successful_durations);

let error_list = error_list.into_iter().flatten();
let error_list = Itertools::flatten(error_list.into_iter());

for e in error_list {
let error_count = self.rustc_statistics
Expand Down
45 changes: 45 additions & 0 deletions tests/cli-rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extern crate tempdir;

use std::fs;
use std::env::consts::EXE_SUFFIX;
use std::path::MAIN_SEPARATOR;
use std::process;
use rustup_utils::raw;
use rustup_mock::clitools::{self, expect_err, expect_ok, expect_ok_ex, expect_stderr_ok,
Expand Down Expand Up @@ -845,6 +846,34 @@ fn show_toolchain_env_not_installed() {
});
}

#[test]
fn show_active_toolchain() {
setup(&|config| {
expect_ok(config, &["rustup", "default", "nightly"]);
expect_ok_ex(
config,
&["rustup", "show", "active-toolchain"],
for_host!(
r"nightly-{0}
"
),
r"",
);
});
}

#[test]
fn show_active_toolchain_none() {
setup(&|config| {
expect_ok_ex(
config,
&["rustup", "show", "active-toolchain"],
r"",
r"",
);
});
}

// #846
#[test]
fn set_default_host() {
Expand Down Expand Up @@ -1390,3 +1419,19 @@ fn file_override_with_target_info() {
);
});
}

#[test]
fn docs_with_path() {
setup(&|config| {
expect_ok(config, &["rustup", "default", "stable"]);

let mut cmd = clitools::cmd(config, "rustup", &["doc", "--path"]);
clitools::env(config, &mut cmd);
let out = cmd.output().unwrap();

let stdout = String::from_utf8(out.stdout).unwrap();
let path = format!("share{}doc{}rust{}html",
MAIN_SEPARATOR, MAIN_SEPARATOR, MAIN_SEPARATOR);
assert!(stdout.contains(path.as_str()));
});
}
43 changes: 34 additions & 9 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,24 @@

<div id="platform-instructions-win32" class="instructions" style="display: none;">
<p>
Download and run
To install Rust, download and run
<a class="windows-download" href="https://win.rustup.rs/i686">rustup&#x2011;init.exe</a>
then follow the onscreen instructions.
</p>
<p class="other-platforms-help">You appear to be running Windows 32 bit. If not, <a class="default-platform-button" href="#">display all supported installers</a>.</p>
<p>If you're a Windows Subsystem for Linux user run the following in your terminal, then follow the onscreen instructions to install Rust.</p>
<pre>curl https://sh.rustup.rs -sSf | sh</pre>
<p class="other-platforms-help">You appear to be running Windows 32-bit. If not, <a class="default-platform-button" href="#">display all supported installers</a>.</p>
</div>

<div id="platform-instructions-win64" class="instructions" style="display: none;">
<p>
Download and run
To install Rust, download and run
<a class="windows-download" href="https://win.rustup.rs/x86_64">rustup&#x2011;init.exe</a>
then follow the onscreen instructions.
</p>
<p class="other-platforms-help">You appear to be running Windows 64 bit. If not, <a class="default-platform-button" href="#">display all supported installers</a>.</p>
<p>If you're a Windows Subsystem for Linux user run the following in your terminal, then follow the onscreen instructions to install Rust.</p>
<pre>curl https://sh.rustup.rs -sSf | sh</pre>
<p class="other-platforms-help">You appear to be running Windows 64-bit. If not, <a class="default-platform-button" href="#">display all supported installers</a>.</p>
</div>

<div id="platform-instructions-unknown" class="instructions" style="display: none;">
Expand Down Expand Up @@ -74,8 +78,18 @@

<div>
<p>
If you are running Windows,<br/>download and run
<a class="windows-download" href="https://win.rustup.rs">rustup&#x2011;init.exe</a>
If you are running Windows 64-bit,<br/>download and run
<a class="windows-download" href="https://win.rustup.rs/x86_64">rustup&#x2011;init.exe</a>
then follow the onscreen instructions.
</p>
</div>

<hr/>

<div>
<p>
If you are running Windows 32-bit,<br/>download and run
<a class="windows-download" href="https://win.rustup.rs/i686">rustup&#x2011;init.exe</a>
then follow the onscreen instructions.
</p>
</div>
Expand All @@ -84,16 +98,27 @@

<div id="platform-instructions-default" class="instructions">
<div>
<p>If you are running Unix,<br/>run the following in your terminal, then follow the onscreen instructions.</p>
<p>To install Rust, if you are running Unix,<br/>run the following
in your terminal, then follow the onscreen instructions.</p>
<pre>curl https://sh.rustup.rs -sSf | sh</pre>
</div>

<hr/>

<div>
<p>
If you are running Windows,<br/>download and run
<a class="windows-download" href="https://win.rustup.rs">rustup&#x2011;init.exe</a>
If you are running Windows 64-bit,<br/>download and run
<a class="windows-download" href="https://win.rustup.rs/x86_64">rustup&#x2011;init.exe</a>
then follow the onscreen instructions.
</p>
</div>

<hr/>

<div>
<p>
If you are running Windows 32-bit,<br/>download and run
<a class="windows-download" href="https://win.rustup.rs/i686">rustup&#x2011;init.exe</a>
then follow the onscreen instructions.
</p>
</div>
Expand Down
5 changes: 4 additions & 1 deletion www/rustup.css
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ hr {
}

#platform-instructions-unix > pre,
#platform-instructions-win32 > pre,
#platform-instructions-win64 > pre,
#platform-instructions-default > div > pre,
#platform-instructions-unknown > div > pre {
background-color: #515151;
Expand All @@ -120,7 +122,8 @@ hr {
box-shadow: inset 0px 0px 20px 0px #333333;
}

#platform-instructions-win a.windows-download,
#platform-instructions-win32 a.windows-download,
#platform-instructions-win64 a.windows-download,
#platform-instructions-default a.windows-download,
#platform-instructions-unknown a.windows-download {
display: block;
Expand Down
Loading

0 comments on commit cd0074b

Please sign in to comment.