Skip to content

Commit d330705

Browse files
committed
Auto merge of #1017 - theindigamer:fix-issue-954, r=brson
Added help for `rustup toolchain link` as documented in issue #954. * Also renamed TOOLCHAIN_INSTALL_HELP -> INSTALL_HELP for consistency.
2 parents 124170c + bd7c369 commit d330705

File tree

5 files changed

+44
-7
lines changed

5 files changed

+44
-7
lines changed

src/rustup-cli/help.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ r"DISCUSSION:
3232
'nightly', or '1.8.0'. For more information see `rustup help
3333
toolchain`.";
3434

35-
pub static TOOLCHAIN_INSTALL_HELP: &'static str =
35+
pub static INSTALL_HELP: &'static str =
3636
r"DISCUSSION:
3737
Installs a specific rust toolchain.
3838
@@ -81,8 +81,29 @@ r"DISCUSSION:
8181
8282
$ rustup default stable-msvc
8383
84-
Toolchain names that don't name a channel instead can be used to
85-
name custom toolchains with the `rustup toolchain link` command.";
84+
rustup can also manage symlinked local toolchain builds, which are
85+
often used to for developing Rust itself. For more information see
86+
`rustup toolchain help link`.";
87+
88+
pub static TOOLCHAIN_LINK_HELP: &'static str =
89+
r"DISCUSSION:
90+
'toolchain' is the custom name to be assigned to the new toolchain.
91+
Any name is permitted as long as it does not fully match an initial
92+
substring of a standard release channel. For example, you can use
93+
the names 'latest' or '2017-04-01' but you cannot use 'stable' or
94+
'beta-i686' or 'nightly-x86_64-unknown-linux-gnu'.
95+
96+
'path' specifies the directory where the binaries and libraries for
97+
the custom toolchain can be found. For example, when used for
98+
development of Rust itself, toolchains can be linked directly out of
99+
the build directory. After building, you can test out different
100+
compiler versions as follows:
101+
102+
$ rustup toolchain link latest-stage1 build/x86_64-unknown-linux-gnu/stage1
103+
$ rustup override set latest-stage1
104+
105+
If you now compile a crate in the current directory, the custom
106+
toolchain 'latest-stage1' will be used.";
86107

87108
pub static OVERRIDE_HELP: &'static str =
88109
r"DISCUSSION:

src/rustup-cli/rustup_mode.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ pub fn cli() -> App<'static, 'static> {
129129
.after_help(SHOW_HELP))
130130
.subcommand(SubCommand::with_name("install")
131131
.about("Update Rust toolchains")
132-
.after_help(TOOLCHAIN_INSTALL_HELP)
132+
.after_help(INSTALL_HELP)
133133
.setting(AppSettings::Hidden) // synonym for 'toolchain install'
134134
.arg(Arg::with_name("toolchain")
135135
.required(true)
@@ -176,6 +176,7 @@ pub fn cli() -> App<'static, 'static> {
176176
.multiple(true)))
177177
.subcommand(SubCommand::with_name("link")
178178
.about("Create a custom toolchain by symlinking to a directory")
179+
.after_help(TOOLCHAIN_LINK_HELP)
179180
.arg(Arg::with_name("toolchain")
180181
.required(true))
181182
.arg(Arg::with_name("path")

src/rustup-mock/src/clitools.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,8 @@ fn mock_bin(_name: &str, version: &str, version_hash: &str) -> Vec<u8> {
693693
fn create_custom_toolchains(customdir: &Path) {
694694
let ref dir = customdir.join("custom-1/bin");
695695
fs::create_dir_all(dir).unwrap();
696+
let ref libdir = customdir.join("custom-1/lib");
697+
fs::create_dir_all(libdir).unwrap();
696698
let rustc = mock_bin("rustc", "1.0.0", "hash-c-1");
697699
let ref path = customdir.join(format!("custom-1/bin/rustc{}", EXE_SUFFIX));
698700
let mut file = File::create(path).unwrap();
@@ -701,6 +703,8 @@ fn create_custom_toolchains(customdir: &Path) {
701703

702704
let ref dir = customdir.join("custom-2/bin");
703705
fs::create_dir_all(dir).unwrap();
706+
let ref libdir = customdir.join("custom-2/lib");
707+
fs::create_dir_all(libdir).unwrap();
704708
let rustc = mock_bin("rustc", "1.0.0", "hash-c-2");
705709
let ref path = customdir.join(format!("custom-2/bin/rustc{}", EXE_SUFFIX));
706710
let mut file = File::create(path).unwrap();

src/rustup/toolchain.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,16 @@ impl<'a> Toolchain<'a> {
275275
pub fn install_from_dir(&self, src: &Path, link: bool) -> Result<()> {
276276
try!(self.ensure_custom());
277277

278+
let mut pathbuf = PathBuf::from(src);
279+
280+
pathbuf.push("lib");
281+
try!(utils::assert_is_directory(&pathbuf));
282+
pathbuf.pop();
283+
pathbuf.push("bin");
284+
try!(utils::assert_is_directory(&pathbuf));
285+
pathbuf.push(format!("rustc{}", EXE_SUFFIX));
286+
try!(utils::assert_is_file(&pathbuf));
287+
278288
if link {
279289
try!(self.install(InstallMethod::Link(&try!(utils::to_absolute(src)))));
280290
} else {

tests/cli-misc.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,11 @@ fn rustup_failed_path_search() {
306306
let ref tool_path = config.exedir.join(&format!("fake_proxy{}", EXE_SUFFIX));
307307
utils::hardlink_file(rustup_path, tool_path).expect("Failed to create fake proxy for test");
308308

309-
expect_ok(config, &["rustup", "toolchain", "link", "empty", &config.emptydir.to_string_lossy()]);
310-
let broken = &["rustup", "run", "empty", "fake_proxy"];
309+
expect_ok(config, &["rustup", "toolchain", "link", "custom",
310+
&config.customdir.join("custom-1").to_string_lossy()]);
311+
let broken = &["rustup", "run", "custom", "fake_proxy"];
311312
expect_err(config, broken, &format!(
312-
"toolchain 'empty' does not have the binary `fake_proxy{}`", EXE_SUFFIX
313+
"toolchain 'custom' does not have the binary `fake_proxy{}`", EXE_SUFFIX
313314
));
314315

315316
// Hardlink will be automatically cleaned up by test setup code

0 commit comments

Comments
 (0)