Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support target-spec json file extension in case-insensitive form #14197

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

boozook
Copy link

@boozook boozook commented Jul 5, 2024

Following rust-lang/rust#127389 to complete it on both sides. Small minor improvement without breaking changes.

Currently user's target json file can have only .json ext, but for file that ends with `.JSON' (in caps).

It could be useful in some old OS and old file-systems such as FAT, for example.

Performance cost:

Approximately no changes.
Comparison using eq_ignore_ascii_case for only latest ext_len chars of the OsStr - using Path::extension with eq_ignore_ascii_case.

Testing

I did not add any new tests for specs, such as with file-extensions like jSoN because minor change and doesn't changes existing behaviour, so existing tests are often. Should I add tests?

Also there is no test because cargo tests requires stable toolchain, but to export host target spec I need nightly, using cmd cargo rustc --bin=cargo --print target-spec-json -Zunstable-options -- -Zunstable-options. Of course, I can hardcode it, but it requires nightly rustc for build-std... 🤔 What I should to do?

How to test:

  1. use rustc from Support target-spec json file extension in various cases rust#127389
  2. rustc --print target-spec-json -Zunstable-options > ./some-target.JSON
  3. remove is-builtin field from the some-target.JSON or set to false
  4. cargo build --target=some-target.JSON should work

Implementation note

I've separated the comparison into a trait with methods for use instead of just str.ends_with(".json") and to maintain future compatibility.
The trait is public for the same reasons and for potential future usage, including other dependent crates.

Questions

  • Name of the trait HasExtIgnoreCase is a good name?
  • The trait probably could be good to place somewhere in crate::util. Or not.

This text looks like a copypasta of that PR. That's not exactly so. The changes are similar, and there are noticeable differences in the two texts. I apologize if this has caused inconvenience.

@rustbot
Copy link
Collaborator

rustbot commented Jul 5, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added A-configuration Area: cargo config files and env vars S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 5, 2024
@boozook boozook marked this pull request as draft July 5, 2024 22:01
@boozook boozook force-pushed the target-spec-json-ext-case-insensitive branch from 958acb5 to 11b5493 Compare July 5, 2024 22:13
@boozook boozook marked this pull request as ready for review July 5, 2024 23:07
@epage epage marked this pull request as draft July 6, 2024 01:17
@epage
Copy link
Contributor

epage commented Jul 6, 2024

Moved to draft as this is dependent on an unreviewed PR in rust-lang/rust for an Issue that hasn't had an MCP.

also implemented that all as trait and share for compat usage, including outer usage of the crate.
@rustbot rustbot added the A-build-execution Area: anything dealing with executing the compiler label Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build-execution Area: anything dealing with executing the compiler A-configuration Area: cargo config files and env vars S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants