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

Refactor scripts to set up Rust on dev desktops #132

Merged
merged 8 commits into from
Nov 2, 2022

Conversation

jdno
Copy link
Member

@jdno jdno commented Oct 10, 2022

The scripts to set up Rust for a user on the dev desktops have been refactored for a better onboarding experience and error handling. The init script installs rustup now, and can be extended in the future to also set the user's git username and email.

For users who want to set up their own Rust toolchain, the setup_rust script clones their fork of the rust-lang/rust repository, compiles it, and links the build artifacts. This is optional, however, and not required if users want to use the dev desktop to work with different repositories.

@jdno
Copy link
Member Author

jdno commented Oct 10, 2022

I missed that the worktree scripts are calling setup_rustup.sh, which will now do a bunch more work. Will take a look at this tomorrow. 🤦‍♂️

@jdno
Copy link
Member Author

jdno commented Oct 18, 2022

The init and setup_rust scripts have been tested on the new instances and seem to work fine. 👍

ansible/roles/dev-desktop/files/scripts/init.sh Outdated Show resolved Hide resolved
ansible/roles/dev-desktop/files/scripts/link_rust.sh Outdated Show resolved Hide resolved
ansible/roles/dev-desktop/files/scripts/link_rust.sh Outdated Show resolved Hide resolved
@@ -13,4 +13,4 @@ git checkout upstream/master
ln -s ../config.toml
Copy link
Member

Choose a reason for hiding this comment

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

this seems somewhat confusing, usually I want different config files in different worktrees. but if no one has complained so far it's probably fine

@jyn514
Copy link
Member

jyn514 commented Oct 21, 2022

@jdno have you seen #132 (comment) ?

@jdno
Copy link
Member Author

jdno commented Oct 27, 2022

@jyn514 I've updated the link_rust script with the changes we talked about yesterday. Tested them in a virtual machine, and everything seems to work fine. 👍

@jyn514
Copy link
Member

jyn514 commented Oct 27, 2022

Looks great, thanks! My last comment is that rust-lang/rust#103286 is landing soon - we may want to either wait until it lands so we can use the new sysroot names unconditionally, or use version detection so this doesn't silently break.

@jdno
Copy link
Member Author

jdno commented Nov 1, 2022

Thanks for the heads-up, @jyn514! What's the best way to detect the version? Can we somehow check the bootstrap version, or should we just go for rustc --version?

@jyn514
Copy link
Member

jyn514 commented Nov 1, 2022

@jdno try this:

; grep 'pub const VERSION' src/bootstrap/lib.rs | grep -o '[0-9]*'
2

I can add a comment to bootstrap saying to keep the version in the same file. Major version 3 is the one that's going to change the sysroot paths; there's not yet a way to test it unless you want to run your script against a checkout of rust-lang/rust#103286.

Looking at the compiler version won't help because it just show 1.66-dev; theoretically you could look at the git hash but that will only work once rust-lang/rust#103286 has landed.

jdno added 7 commits November 1, 2022 16:50
The scripts to set up Rust for a user on the dev desktops have been
refactored for a better onboarding experience and error handling. The
init script installs rustup now, and can be extended in the future to
also set the user's git username and email.

For users who want to set up their own Rust toolchain, the setup_rust
script clones their fork of the rust-lang/rust repository, compiles it,
and links the build artifacts. This is optional, however, and not
required if users want to use the dev desktop to work with different
repositories.
A new script has been created to link the build artifacts. The script is
called from the init script that sets up Rust, and from the script that
initializes a new worktree.
The dev desktops are deployed to machines with different architectures
(amd64 and arm64), which makes it necessary to discover the target
triple when linking the stages. The current solution was chosen based on
the following Stack Overflow post:

https://stackoverflow.com/questions/52996949/how-can-i-find-the-current-rust-compilers-default-llvm-target-triple
The directory names for the stages are changing in version 3 of the
boostrapping (see rust-lang/rust#103286). We are
checking the version now to create the correct dummy directories.
@jdno jdno force-pushed the refactor-dev-desktop-scripts branch from aefbcf5 to 9287abf Compare November 2, 2022 08:53
@jdno
Copy link
Member Author

jdno commented Nov 2, 2022

I've added the grep command and an if block to handle the two different versions. Also rebased the branch to resolve a merge conflict after merging #110.

@jdno
Copy link
Member Author

jdno commented Nov 2, 2022

Thanks so much for the help, @jyn514! <3

@jdno jdno merged commit 78613eb into rust-lang:master Nov 2, 2022
@jdno jdno deleted the refactor-dev-desktop-scripts branch November 2, 2022 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants