This repository has been archived by the owner on Dec 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable users to specify toolchain to use (#267)
- Loading branch information
1 parent
6940183
commit fd01859
Showing
8 changed files
with
388 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Common Configuration Parameters | ||
|
||
## rustup | ||
|
||
Users should adjust properties of this configuration parameter to customize rustup. | ||
|
||
### toolchain | ||
|
||
This configuration parameter specifies which toolchain the extension will invoke rustup with. | ||
It is used for getting sysroot, installing components. | ||
|
||
However there are few exceptions. Currently RLS is available for nightly hence RLS and rust-analysis are installed for the nightly toolchain. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
export class Toolchain { | ||
public static readonly defaultToolchainPrefix: string = ' (default)'; | ||
|
||
/** | ||
* "stable" in "stable-x86_64-pc-windows-msvc (default)" | ||
*/ | ||
public readonly channel: string; | ||
|
||
/** | ||
* "x86_64-pc-windows-msvc" in "stable-x86_64-pc-windows-msvc (default)" | ||
* `undefined` in "stable" | ||
*/ | ||
public readonly host: string | undefined; | ||
|
||
/** | ||
* true in "stable-x86_64-pc-windows-msvc (default)". | ||
* false in "stable-x86_64-pc-windows-msvc" | ||
*/ | ||
public readonly isDefault: boolean; | ||
|
||
/** | ||
* Tries to parse the text and if returns the toolchain parsed from the text | ||
* @param text The text to parse | ||
* @return the toolchain or undefined | ||
*/ | ||
public static parse(text: string): Toolchain | undefined { | ||
const sepIndex = text.indexOf('-'); | ||
const channelEnd = sepIndex === -1 ? undefined : sepIndex; | ||
const channel = text.substring(0, channelEnd); | ||
if (channelEnd === undefined) { | ||
// The text represents the toolchain with the only channel. | ||
return new Toolchain(channel, undefined, false); | ||
} | ||
const spaceIndex = text.indexOf(' ', sepIndex); | ||
const hostEnd = spaceIndex === -1 ? undefined : spaceIndex; | ||
const host = text.substring(sepIndex + 1, hostEnd); | ||
const isDefault = text.endsWith(Toolchain.defaultToolchainPrefix); | ||
return new Toolchain(channel, host, isDefault); | ||
} | ||
|
||
public equals(toolchain: Toolchain): boolean { | ||
return this.channel === toolchain.channel && this.host === toolchain.host; | ||
} | ||
|
||
public toString(includeHost: boolean, includeIsDefault: boolean): string { | ||
let s = this.channel.concat(); | ||
if (includeHost && this.host) { | ||
s += '-'; | ||
s += this.host; | ||
} | ||
if (includeIsDefault && this.isDefault) { | ||
s += Toolchain.defaultToolchainPrefix; | ||
} | ||
return s; | ||
} | ||
|
||
private constructor(channel: string, host: string | undefined, isDefault: boolean) { | ||
this.channel = channel; | ||
this.host = host; | ||
this.isDefault = isDefault; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.