Make target-spec json file extensions case-insensitive by boozook · Pull Request #127389 · rust-lang/rust (original) (raw)
Conversation
This file contains hidden or 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
[ Show hidden characters]({{ revealButtonHref }})
rustbot added S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
boozook marked this pull request as ready for review
bors added a commit to rust-lang-ci/rust that referenced this pull request
…sensitive, r=
Support target-spec json file extension in various cases
Currently user's target json file can have only json
ext, but cannot have `JSON' or any other strange form.
This is a little fix with added support of case-insensitive file-ext for user specified target only. That means that not supported in following cases:
- any directory traversal, such as in
$RUST_TARGET_PATH
- same for
rustc_target::spec::Target::search
, so it doesn't work withJSON
on case-sensitive FS, but works fine on case-insensitive FS. $RUST_TARGET_PATH
dir traversal in the bootstrap is not touched too.
Performance cost:
Almost without changes.
Comparison using eq_ignore_ascii_case
for only latest ext_len chars of the OsStr
(as bytes).
Testing
How to test:
rustc --print target-spec-json -Zunstable-options > ./some-target.JSON
- remove
is-builtin
field from thesome-target.JSON
or set tofalse
rustc --print target-spec-json -Zunstable-options --target=some-target.JSON
should workrustc --print target-spec-json -Zunstable-options --target=some-target
should work on case-insensitive FSrustc --print cfg --target=some-target
should work too, on case-insensitive FS
Tests added.
Implementation note
I've separated the comparison into a method for potential future use instead of just str.ends_with(".json")
and to maintain compatibility.
The method is public for the same reasons.
Fixes rust-lang#127387 issue.
try-job: test-various try-job: armhf-gnu try-job: x86_64-msvc try-job: aarch64-apple
bors added a commit to rust-lang-ci/rust that referenced this pull request
…sensitive, r=
Support target-spec json file extension in various cases
Currently user's target json file can have only json
ext, but cannot have `JSON' or any other strange form.
This is a little fix with added support of case-insensitive file-ext for user specified target only. That means that not supported in following cases:
- any directory traversal, such as in
$RUST_TARGET_PATH
- same for
rustc_target::spec::Target::search
, so it doesn't work withJSON
on case-sensitive FS, but works fine on case-insensitive FS. $RUST_TARGET_PATH
dir traversal in the bootstrap is not touched too.
Performance cost:
Almost without changes.
Comparison using eq_ignore_ascii_case
for only latest ext_len chars of the OsStr
(as bytes).
Testing
How to test:
rustc --print target-spec-json -Zunstable-options > ./some-target.JSON
- remove
is-builtin
field from thesome-target.JSON
or set tofalse
rustc --print target-spec-json -Zunstable-options --target=some-target.JSON
should workrustc --print target-spec-json -Zunstable-options --target=some-target
should work on case-insensitive FSrustc --print cfg --target=some-target
should work too, on case-insensitive FS
Tests added.
Implementation note
I've separated the comparison into a method for potential future use instead of just str.ends_with(".json")
and to maintain compatibility.
The method is public for the same reasons.
Fixes rust-lang#127387 issue.
try-job: test-various try-job: armhf-gnu try-job: x86_64-msvc try-job: aarch64-apple
bors added a commit to rust-lang-ci/rust that referenced this pull request
…sensitive, r=
Support target-spec json file extension in various cases
Currently user's target json file can have only json
ext, but cannot have `JSON' or any other strange form.
This is a little fix with added support of case-insensitive file-ext for user specified target only. That means that not supported in following cases:
- any directory traversal, such as in
$RUST_TARGET_PATH
- same for
rustc_target::spec::Target::search
, so it doesn't work withJSON
on case-sensitive FS, but works fine on case-insensitive FS. $RUST_TARGET_PATH
dir traversal in the bootstrap is not touched too.
Performance cost:
Almost without changes.
Comparison using eq_ignore_ascii_case
for only latest ext_len chars of the OsStr
(as bytes).
Testing
How to test:
rustc --print target-spec-json -Zunstable-options > ./some-target.JSON
- remove
is-builtin
field from thesome-target.JSON
or set tofalse
rustc --print target-spec-json -Zunstable-options --target=some-target.JSON
should workrustc --print target-spec-json -Zunstable-options --target=some-target
should work on case-insensitive FSrustc --print cfg --target=some-target
should work too, on case-insensitive FS
Tests added.
Implementation note
I've separated the comparison into a method for potential future use instead of just str.ends_with(".json")
and to maintain compatibility.
The method is public for the same reasons.
Fixes rust-lang#127387 issue.
try-job: test-various try-job: armhf-gnu try-job: x86_64-msvc try-job: aarch64-apple
tgross35 changed the title
Support target-spec json file extension in various cases Make target-spec json file extensions case insensitive
tgross35 changed the title
Make target-spec json file extensions case insensitive Make target-spec json file extensions case-insensitive
davidtwco added S-waiting-on-author
Status: This is awaiting some action (such as code changes or more information) from the author.
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels