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

Fix x setup -h -v should work #96584

Merged
merged 1 commit into from
Dec 18, 2022

Conversation

bentongxyz
Copy link
Contributor

r? @jyn514

I have to convert profile to path and back in order to remove special-casing in bootstrap. I also check for dry_run so that config.toml and/ or .git/hooks/pre-push will not be created if --dry-run is specified.

Please help me see if this is ok, thanks alot!

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this! It looks like basically the right approach, I just have a few comments on the implementation.

I also noticed that the should_run step is never actually hit, because setup is still special-cased in Flags::parse. Is it possible to remove that special-casing? You should double check that x setup without arguments still works (you probably will need to add DEFAULT = true in the Step impl) and that x setup invalid properly goes through the "no paths matched" path instead of "called unwrap on None".

One super cool thing to do is to still keep the description of each path, like it has currently:

Arguments:
    This subcommand accepts a 'profile' to use for builds. For example:

        ./x.py setup library

    The profile is optional and you will be prompted interactively if it is not given.
    The following profiles are available:

        library: Contribute to the standard library
        compiler: Contribute to the compiler itself
        codegen: Contribute to the compiler, and also modify LLVM or codegen
        tools: Contribute to tools which depend on the compiler, but do not modify it directly (e.g. rustdoc, clippy, miri)
        user: Install Rust from source

That will probably require modifying ShouldRun to allow passing in a description for the alias, though - no need to tackle it just now if it's tricky.

r? @Mark-Simulacrum just so this has someone assigned, but happy to be in charge of the review.

src/bootstrap/flags.rs Outdated Show resolved Hide resolved
src/bootstrap/setup.rs Show resolved Hide resolved
src/bootstrap/setup.rs Outdated Show resolved Hide resolved
@bentongxyz
Copy link
Contributor Author

Hi @jyn514, quick question here

I am working on changing Setup to take a single path, but here at builder.rs line 715, I have trouble converting single path to &[PathBuf] to be compatible with other match arms type:

If I do Subcommand::Setup { ref path } => (Kind::Setup, &[path.clone()])

Error: expected slice, found array of 1 element

If i do Subcommand::Setup { ref path } => (Kind::Setup, &[path.clone()][..])

Error: temporary value dropped while borrowed
creates a temporary which is freed while still in use

I am abit stuck here, what is the best way to approach this?

Thanks a bunch!

@jyn514
Copy link
Member

jyn514 commented May 1, 2022

@bentongxyz I think it will work if you remove the call to clone: (Kind::Setup, &[path][..])

@bentongxyz
Copy link
Contributor Author

@jyn514 still no good, if I do (Kind::Setup, &[path][..]), I got from the compiler:

expected struct std::path::PathBuf, found &std::path::PathBuf

@bentongxyz
Copy link
Contributor Author

@jyn514 still no good, if I do (Kind::Setup, &[path][..]), I got from the compiler:

expected struct std::path::PathBuf, found &std::path::PathBuf

Thank you for your review!
Except for the above part, I have updated the code.

One super cool thing to do is to still keep the description of each path, like it has currently:

....

That will probably require modifying ShouldRun to allow passing in a description for the alias, though - no need to tackle it just now if it's tricky.

If this is ok, maybe this could be the goal for my next PR? I am looking for further work to do for the project too :)

@jyn514
Copy link
Member

jyn514 commented May 2, 2022

@bentongxyz try this:

            Subcommand::Setup { ref path } => (Kind::Setup, if let Some(p) = path { std::slice::from_ref(p) } else { &[] }),

(this assumes path is an Option - we should still allow x setup without arguments.)

If this is ok, maybe this could be the goal for my next PR? I am looking for further work to do for the project too :)

Sounds great! thanks for working on this :)

@rustbot label +A-rustbuild +S-waiting-on-author +C-cleanup

src/bootstrap/builder.rs Outdated Show resolved Hide resolved
@rustbot rustbot added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 3, 2022
@rustbot
Copy link
Collaborator

rustbot commented May 3, 2022

Error: The "Ready" shortcut only works on pull requests.

Please let @rust-lang/release know if you're having trouble with this bot.

@jyn514
Copy link
Member

jyn514 commented May 3, 2022

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 3, 2022
@rust-log-analyzer

This comment has been minimized.

src/bootstrap/setup.rs Outdated Show resolved Hide resolved
@bentongxyz
Copy link
Contributor Author

r? @Mark-Simulacrum

@bors
Copy link
Contributor

bors commented May 9, 2022

☔ The latest upstream changes (presumably #96846) made this pull request unmergeable. Please resolve the merge conflicts.

@bentongxyz
Copy link
Contributor Author

Hi @jyn514, in the meantime, please let me know if there is anything that I can work on :)

@jyn514
Copy link
Member

jyn514 commented May 9, 2022

Hi @bentongxyz - #86890 is a good issue to try out (it's a little harder to test than this one, but not too bad), or you could go with the first approach I mentioned in #96584 (comment) so you don't have to wait for my PR to land.

@rustbot label -S-waiting-on-review +S-blocked

@rustbot rustbot added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 9, 2022
Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for the PR :)

src/bootstrap/setup.rs Outdated Show resolved Hide resolved
@bentongxyz
Copy link
Contributor Author

#86890 is a good issue to try out (it's a little harder to test than this one, but not too bad), or you could go with the first approach I mentioned in #96584 (comment) so you don't have to wait for my PR to land.

@jyn514 Thank you! I will take a look at #86890.

Meanwhile, I made changes to impl Step for Profile so it is more explicit that it is a temporary hack (reference).

See if it is okay for merge without needing #96501 to land first.

I can also help refactor it after #96501 is done!

@apiraino apiraino added the T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. label May 23, 2022
@Dylan-DPC
Copy link
Member

Thanks. We don't accept merge commits on this repo so kindly unmerge it and rebase it instead.

@bentongxyz
Copy link
Contributor Author

You marked this as resolved, but I still see multiple paths - did you run into trouble?

some changes were reverted following this comment #96584 (comment) , I have changed back to single path, please see the new commit :)

@bentongxyz
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 8, 2022
@jyn514
Copy link
Member

jyn514 commented Nov 17, 2022

@bors r+ rollup

Sorry for the long delay! This looks good :)

@bors
Copy link
Contributor

bors commented Nov 17, 2022

📌 Commit b2bc65b has been approved by jyn514

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Nov 17, 2022

🌲 The tree is currently closed for pull requests below priority 1. This pull request will be tested once the tree is reopened.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 17, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 17, 2022
… r=jyn514

Fix `x setup -h -v` should work

r? `@jyn514`

I have to convert profile to path and back in order to remove special-casing in bootstrap. I also check for `dry_run` so that `config.toml` and/ or `.git/hooks/pre-push` will not be created if `--dry-run` is specified.

Please help me see if this is ok, thanks alot!
@matthiaskrgr
Copy link
Member

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 17, 2022
@jyn514
Copy link
Member

jyn514 commented Nov 17, 2022

@bentongxyz you need to rebase one last time, dry_run changed from a field to a function

@bors
Copy link
Contributor

bors commented Dec 6, 2022

☔ The latest upstream changes (presumably #105328) made this pull request unmergeable. Please resolve the merge conflicts.

- Remove setup special-casing in Flags::parse
@@ -351,7 +351,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",

// fn usage()
let usage = |exit_code: i32, opts: &Options, verbose: bool, subcommand_help: &str| -> ! {
let config = Config::parse(&["build".to_string()]);
let config = Config::parse(&["setup".to_string()]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change is so x setup one two doesn't update submodules before showing the usage error

@jyn514
Copy link
Member

jyn514 commented Dec 17, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Dec 17, 2022

📌 Commit fca8290 has been approved by jyn514

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 17, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 18, 2022
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#96584 (Fix `x setup -h -v` should work)
 - rust-lang#105420 (Remove dead code after destination propagation)
 - rust-lang#105844 (Make the x tool use the x and x.ps1 scripts)
 - rust-lang#105854 (remove redundant clone)
 - rust-lang#105858 (Another `as_chunks` example)
 - rust-lang#105870 (avoid .into() conversion to identical types)
 - rust-lang#105875 (don't destuct references just to reborrow)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3fb5d8e into rust-lang:master Dec 18, 2022
@rustbot rustbot added this to the 1.68.0 milestone Dec 18, 2022
@bentongxyz bentongxyz deleted the x-setup-h-v-should-work branch March 16, 2023 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants