Skip to content

Commit

Permalink
Restore behavior to not touch existing RUSTFLAGS variable
Browse files Browse the repository at this point in the history
Add changelog
  • Loading branch information
jonasbb committed May 29, 2023
1 parent 70241ab commit 1ef811f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Before only the items listed in `rust-toolchain` were installed.
Now all the items from the toolchain file are installed and then all the `target`s and `components` that are provided as action inputs.
This allows installing extra tools only for CI or simplify testing special targets in CI.
* Allow skipping the creation of a `RUSTFLAGS` environment variable.
Cargos logic for rustflags is complicated, and setting the `RUSTFLAGS` environment variable prevents other ways of working.
Provide a new `rustflags` input, which controls the environment variable creation.
If the value is set to the empty string, then `RUSTFLAGS` is not created.

Pre-existing `RUSTFLAGS` variables are never modified by this extension.

## [1.4.4] - 2023-03-18

Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ Afterward, the `components` and `target` specified via inputs are installed in a
### RUSTFLAGS

By default, this action sets the `RUSTFLAGS` environment variable to `-D warnings`.
However, rustflags sources are mutually exclusive, so setting this environment variable omits any configuration through `target.*.rustflags` or `build.rustflags`.

However, rustflags sources are mutually exclusive, so setting this environment
variable omits any configuration through `target.*.rustflags` or
`build.rustflags`.
* If `RUSTFLAGS` is already set, no modifications of the variable are made and the original value remains.
* If `RUSTFLAGS` is unset and the `rustflags` input is empty (i.e., the empty string), then it will remain unset.
Use this, if you want to prevent the value from being set because you make use of `target.*.rustflags` or `build.rustflags`.
* Otherwise, the environment variable `RUSTFLAGS` is set to the content of `rustflags`.

To prevent this from happening, set the `rustflags` input to an empty string, which will
prevent the action from setting `RUSTFLAGS` at all, keeping any existing preferences.
Expand All @@ -82,4 +84,4 @@ License].

[MIT License]: LICENSE
[Problem Matchers]: https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md
[Cargo reference]: https://doc.rust-lang.org/cargo/reference/config.html?highlight=unknown#buildrustflags
[Cargo reference]: https://doc.rust-lang.org/cargo/reference/config.html?highlight=unknown#buildrustflags
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ runs:
if [[ ! -v RUST_BACKTRACE ]]; then
echo "RUST_BACKTRACE=short" >> $GITHUB_ENV
fi
if [[ "$NEW_RUSTFLAGS" != "" ]]; then
if [[ ( ! -v RUSTFLAGS ) && $NEW_RUSTFLAGS != "" ]]; then
echo "RUSTFLAGS=$NEW_RUSTFLAGS" >> $GITHUB_ENV
fi
# Enable faster sparse index on nightly
Expand Down

0 comments on commit 1ef811f

Please sign in to comment.