Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
27 changes: 24 additions & 3 deletions src/rustup-cli/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ the same as `rustup toolchain install`.
'toolchain' specifies a toolchain name, such as 'stable', 'nightly',
or '1.8.0'. For more information see `rustup help toolchain`.";

pub static TOOLCHAIN_INSTALL_HELP: &'static str =
pub static INSTALL_HELP: &'static str =
r"
Installs a specific rust toolchain.

Expand Down Expand Up @@ -77,8 +77,29 @@ inferred, so the above could be written:

$ rustup default stable-msvc

Toolchain names that don't name a channel instead can be used to name
custom toolchains with the `rustup toolchain link` command.";
rustup can also manage symlinked local toolchain builds, which are
often used to for developing Rust itself. For more information see
`rustup toolchain help link`.";

pub static TOOLCHAIN_LINK_HELP: &'static str =
r"DISCUSSION:
'toolchain' is the custom name to be assigned to the new toolchain.
Any name is permitted as long as it does not fully match an initial
substring of a standard release channel. For example, you can use
the names 'latest' or '2017-04-01' but you cannot use 'stable' or
'beta-i686' or 'nightly-x86_64-unknown-linux-gnu'.

'path' specifies the directory where the binaries and libraries for
the custom toolchain can be found. For example, when used for
development of Rust itself, toolchains can be linked directly out of
the build directory. After building, you can test out different
compiler versions as follows:

$ rustup toolchain link latest-stage1 build/x86_64-unknown-linux-gnu/stage1
$ rustup override set latest-stage1

If you now compile a crate in the current directory, the custom
toolchain 'latest-stage1' will be used.";

pub static OVERRIDE_HELP: &'static str =
r"
Expand Down
15 changes: 12 additions & 3 deletions src/rustup-cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustup_dist::manifest::Component;
use rustup_dist::dist::{TargetTriple, PartialToolchainDesc, PartialTargetTriple};
use rustup_utils::utils;
use self_update;
use std::path::Path;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::iter;
use term2;
Expand Down Expand Up @@ -128,7 +128,7 @@ pub fn cli() -> App<'static, 'static> {
.after_help(SHOW_HELP))
.subcommand(SubCommand::with_name("install")
.about("Update Rust toolchains")
.after_help(TOOLCHAIN_INSTALL_HELP)
.after_help(INSTALL_HELP)
.setting(AppSettings::Hidden) // synonym for 'toolchain install'
.arg(Arg::with_name("toolchain")
.required(true)))
Expand Down Expand Up @@ -167,6 +167,7 @@ pub fn cli() -> App<'static, 'static> {
.multiple(true)))
.subcommand(SubCommand::with_name("link")
.about("Create a custom toolchain by symlinking to a directory")
.after_help(TOOLCHAIN_LINK_HELP)
.arg(Arg::with_name("toolchain")
.required(true))
.arg(Arg::with_name("path")
Expand Down Expand Up @@ -687,7 +688,15 @@ fn toolchain_link(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
let ref toolchain = m.value_of("toolchain").expect("");
let ref path = m.value_of("path").expect("");
let toolchain = try!(cfg.get_toolchain(toolchain, true));

let mut pathbuf = PathBuf::from(path);

pathbuf.push("lib");
try!(utils::assert_is_directory(&pathbuf));
pathbuf.pop();
pathbuf.push("bin");
try!(utils::assert_is_directory(&pathbuf));
pathbuf.push("rustc");
try!(utils::assert_is_file(&pathbuf));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with adding this validation, but will you sink it into the toolchain.install_from_dir call below? This file is purely for argument parsing.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brson Done. I've added it to the top of the function as install_from_dir may be used in the future with link=false but it would still require checking the directory structure correctly in that case.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, sorry I had to change one line (remove the added dependency on PathBuf) so I rebased locally. (That's why the first commit link below is dead.)

Ok(try!(toolchain.install_from_dir(Path::new(path), true)))
}

Expand Down