add support for multiple targets

This commit is contained in:
Douglas Campos 2020-03-13 23:25:35 +00:00
parent 23cd1093e2
commit 1aa194cceb
4 changed files with 14 additions and 8 deletions

View File

@ -42,7 +42,7 @@ See [additional recipes here](https://github.com/actions-rs/meta).
| Name | Required | Description | Type | Default | | Name | Required | Description | Type | Default |
| ------------ | :------: | ----------------------------------------------------------------------------------------------------------------------------------------------------| ------ | --------| | ------------ | :------: | ----------------------------------------------------------------------------------------------------------------------------------------------------| ------ | --------|
| `toolchain` | | [Toolchain](https://github.com/rust-lang/rustup.rs#toolchain-specification) name to use, ex. `stable`, `nightly`, `nightly-2019-04-20`, or `1.32.0` | string | | | `toolchain` | | [Toolchain](https://github.com/rust-lang/rustup.rs#toolchain-specification) name to use, ex. `stable`, `nightly`, `nightly-2019-04-20`, or `1.32.0` | string | |
| `target` | | Additionally install specified target for this toolchain, ex. `x86_64-apple-darwin` | string | | | `targets` | | Additionally install specified targets for this toolchain, ex. `x86_64-apple-darwin` | string | |
| `default` | | Set installed toolchain as a default toolchain | bool | false | | `default` | | Set installed toolchain as a default toolchain | bool | false |
| `override` | | Set installed toolchain as an override for the current directory | bool | false | | `override` | | Set installed toolchain as an override for the current directory | bool | false |
| `profile` | | Execute `rustup set profile {value}` before installing the toolchain, ex. `minimal` | string | | | `profile` | | Execute `rustup set profile {value}` before installing the toolchain, ex. `minimal` | string | |

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@ import {existsSync, readFileSync} from 'fs';
export interface ToolchainOptions { export interface ToolchainOptions {
name: string, name: string,
target: string | undefined, targets: string[] | undefined,
default: boolean, default: boolean,
override: boolean, override: boolean,
profile: string | undefined, profile: string | undefined,
@ -12,6 +12,11 @@ export interface ToolchainOptions {
} }
export function toolchain_args(overrideFile: string): ToolchainOptions { export function toolchain_args(overrideFile: string): ToolchainOptions {
let targets: string[] | undefined = input.getInputList('targets');
if (targets && targets.length === 0) {
targets = undefined;
}
let components: string[] | undefined = input.getInputList('components'); let components: string[] | undefined = input.getInputList('components');
if (components && components.length === 0) { if (components && components.length === 0) {
components = undefined; components = undefined;
@ -19,7 +24,7 @@ export function toolchain_args(overrideFile: string): ToolchainOptions {
return { return {
name: determineToolchain(overrideFile), name: determineToolchain(overrideFile),
target: input.getInput('target') || undefined, targets: targets,
default: input.getInputBool('default'), default: input.getInputBool('default'),
override: input.getInputBool('override'), override: input.getInputBool('override'),
profile: input.getInput('profile') || undefined, profile: input.getInput('profile') || undefined,

View File

@ -50,10 +50,11 @@ async function run() {
} }
await rustup.installToolchain(opts.name, installOptions); await rustup.installToolchain(opts.name, installOptions);
if (opts.target) { if (opts.targets) {
await rustup.addTarget(opts.target, opts.name); for (let target of opts.targets) {
} await rustup.addTarget(target, opts.name);
}
}
await versions.gatherInstalledVersions(); await versions.gatherInstalledVersions();
} }