-
Notifications
You must be signed in to change notification settings - Fork 84
Refactor scripts to set up Rust on dev desktops #132
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
98b197c
Rewrite scripts to set up Rust on dev desktops
jdno 19edc68
Create script to link build artifacts
jdno 9407260
Discover target triple
jdno bea2384
Remove build command from link script
jdno d52d8bb
Restore original name for init script
jdno 232dad9
Link fake sysroot when setting up Rust
jdno 9287abf
Detect bootstrap version to link correct paths
jdno 0da6994
Future-proof bootstrap version check
jdno File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "# Available scripts for managing your Rust checkouts" | ||
echo "init.sh | first time setup, you should only have to execute this once on a new machine" | ||
echo "setup_rustup.sh | first time setup, you should only have to execute this once on a new machine" | ||
echo "status.sh | list the branches and git status of all copies of the Rust repo" | ||
echo "new_worktree.sh | creates a worktree (shallow copy of the main git checkout of Rust, sharing the .git folder)" | ||
echo "detach_merged_prs.sh | invokes \"git pull --fast-forward-only\" on all worktrees and detaches those that are equal to the \"master\" branch" | ||
echo "" | ||
echo "# Rarer commands:" | ||
echo "set_defaults.sh | connects the global config.toml with all worktrees. Use this when your setup is broken" | ||
|
||
echo "set_defaults.sh | connects the global config.toml with all worktrees. Use this when your setup is broken" | ||
echo "setup_rust.sh | Clone your fork of rust-lang/rust, compile, and then link it" |
14 changes: 4 additions & 10 deletions
14
ansible/roles/dev-desktop/files/scripts/init.sh
100755 → 100644
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
username=`id -u -n` | ||
gh_name=${username#"gh-"} | ||
|
||
# Using https instead of git urls because vscode only handles login on push/pull | ||
git clone https://github.com/$gh_name/rust.git | ||
pushd rust | ||
git remote add upstream https://github.com/rust-lang/rust.git | ||
git fetch upstream | ||
git checkout upstream/master | ||
popd | ||
# Enable strict mode for Bash | ||
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
init_git.py | ||
setup_rustup.sh |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Enable strict mode for Bash | ||
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
# Discover target triple (e.g. "aarch64-unknown-linux-gnu") | ||
target="$(rustc -vV | awk '/host/ { print $2 }')" | ||
|
||
rustc_dummy=$( | ||
cat <<EOF | ||
#!/usr/bin/env bash | ||
echo "This is a dummy file to trick rustup into thinking this is a sysroot" | ||
echo 'Run "x.py build --stage 1 library/std" to create a real sysroot you can use with rustup' | ||
EOF | ||
) | ||
|
||
for D in rust*; do | ||
if [ -d "$D" ]; then | ||
pushd "$D" | ||
|
||
bootstrap_version=$(grep 'pub const VERSION' src/bootstrap/lib.rs | grep -o '[0-9]*') | ||
|
||
if [ "$bootstrap_version" -gt 2 ]; then | ||
stages=(stage1-sysroot stage2-sysroot) | ||
else | ||
stages=(stage1 stage2) | ||
fi | ||
|
||
for stage in "${stages[@]}"; do | ||
directory="build/${target}/${stage}" | ||
|
||
if [ ! -d "$directory" ]; then | ||
mkdir -p "${directory}/lib" | ||
mkdir -p "${directory}/bin" | ||
echo "$rustc_dummy" >> "${directory}/bin/rustc" | ||
chmod +x "${directory}/bin/rustc" | ||
fi | ||
|
||
rustup toolchain link "${D}_${stage}" "$directory" | ||
done | ||
|
||
popd | ||
fi | ||
done |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,4 @@ git checkout upstream/master | |
ln -s ../config.toml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
popd | ||
|
||
setup_rustup.sh | ||
link_rust.sh |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Enable strict mode for Bash | ||
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
for D in rust*; do | ||
if [ -d "${D}" ]; then | ||
pushd $D | ||
ln -s ../config.toml | ||
popd | ||
pushd "${D}" || exit | ||
if [[ ! -f config.toml ]]; then | ||
ln -s ~/config.toml . | ||
fi | ||
popd || exit | ||
fi | ||
done |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Enable strict mode for Bash | ||
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
username=$(id -u -n) | ||
gh_name=${username#"gh-"} | ||
|
||
set -x | ||
|
||
if [[ ! -d "rust" ]]; then | ||
# Using https instead of git urls because vscode only handles login on push/pull | ||
git clone "https://github.com/${gh_name}/rust.git" | ||
fi | ||
|
||
pushd rust | ||
|
||
if ! git remote | grep upstream; then | ||
git remote add upstream https://github.com/rust-lang/rust.git | ||
fi | ||
|
||
git fetch upstream | ||
git checkout upstream/master | ||
popd | ||
|
||
set_defaults.sh | ||
link_rust.sh | ||
jdno marked this conversation as resolved.
Show resolved
Hide resolved
|
25 changes: 13 additions & 12 deletions
25
ansible/roles/dev-desktop/files/scripts/setup_rustup.sh
100644 → 100755
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -x | ||
|
||
rustup --version || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
|
||
source "$HOME/.cargo/env" | ||
|
||
for D in rust*; do | ||
if [ -d "${D}" ]; then | ||
rustup toolchain link "$D"_stage1 "$D/build/x86_64-unknown-linux-gnu/stage1" | ||
rustup toolchain link "$D"_stage2 "$D/build/x86_64-unknown-linux-gnu/stage2" | ||
fi | ||
done | ||
# Enable strict mode for Bash | ||
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
# Check if rustup is already installed and exit if that's the case. | ||
if command -v rustup &>/dev/null; then | ||
rustup --version | ||
exit 0 | ||
fi | ||
|
||
echo "Installing rustup..." | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.