Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Support multiple targets #217

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.0] - 2021-07-19

### Added

- `targets` input now takes a comma-separated list of targets rather than a single target

### Changed

- `target` input is now an alias for `targets`

## [1.0.6] - 2020-03-24

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ See [additional recipes here](https://github.com/actions-rs/meta).
| 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 | stable |
| `target` | | Additionally install specified target for this toolchain, ex. `x86_64-apple-darwin` | string | |
| `targets` | | Comma-separated list of additional targets to install for this toolchain, ex. `x86_64-apple-darwin` | string | |
| `default` | | Set installed toolchain as a default toolchain | 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 | default |
Expand Down
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ inputs:

If this is not given, the action will try and install the version specified in the `rust-toolchain` file.
required: false
targets:
description: Comma-separated list of additional target triples to install for this toolchain
required: false
target:
description: Target triple to install for this toolchain
description: Alias for `targets`
required: false
default:
description: Set installed toolchain as default
Expand Down
9 changes: 7 additions & 2 deletions src/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { existsSync, readFileSync } from "fs";

export interface ToolchainOptions {
name: string;
target: string | undefined;
targets: string | undefined;
default: boolean;
override: boolean;
profile: string | undefined;
Expand Down Expand Up @@ -41,9 +41,14 @@ export function getToolchainArgs(overrideFile: string): ToolchainOptions {
components = undefined;
}

let targets: string[] | undefined = input.getInputList("targets") || input.getInputList("target");
if (targets && targets.length === 0) {
targets = undefined;
}

return {
name: determineToolchain(overrideFile),
target: input.getInput("target") || undefined,
targets: targets,
default: input.getInputBool("default"),
override: input.getInputBool("override"),
profile: input.getInput("profile") || undefined,
Expand Down
6 changes: 4 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ async function run(): Promise<void> {

await rustup.installToolchain(opts.name, installOptions);

if (opts.target) {
await rustup.addTarget(opts.target, opts.name);
if (opts.targets) {
for (const target of opts.targets) {
await rustup.addTarget(target, opts.name);
}
}

await versions.gatherInstalledVersions();
Expand Down