Skip to content

Commit aefbcf5

Browse files
committed
Link fake sysroot when setting up Rust
1 parent 94c696a commit aefbcf5

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

ansible/roles/dev-desktop/files/scripts/link_rust.sh

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,32 @@ IFS=$'\n\t'
88
# Discover target triple (e.g. "aarch64-unknown-linux-gnu")
99
target="$(rustc -vV | awk '/host/ { print $2 }')"
1010

11+
rustc_dummy=$(
12+
cat <<EOF
13+
#!/usr/bin/env bash
14+
echo "This is a dummy file to trick rustup into thinking this is a sysroot"
15+
echo 'Run "x.py build --stage 1 library/std" to create a real sysroot you can use with rustup'
16+
EOF
17+
)
18+
19+
stages=(stage1 stage2)
20+
1121
for D in rust*; do
12-
if [ -d "${D}" ]; then
13-
pushd "${D}"
22+
if [ -d "$D" ]; then
23+
pushd "$D"
24+
25+
for stage in "${stages[@]}"; do
26+
directory="build/${target}/${stage}"
1427

15-
if [[ -d "$D/build/$target/stage1" ]]; then
16-
rustup toolchain link "$D"_stage1 "$D/build/$target/stage1"
17-
fi
28+
if [ ! -d "$directory" ]; then
29+
mkdir -p "${directory}/lib"
30+
mkdir -p "${directory}/bin"
31+
echo "$rustc_dummy" >> "${directory}/bin/rustc"
32+
chmod +x "${directory}/bin/rustc"
33+
fi
1834

19-
if [[ -d "$D/build/$target/stage2" ]]; then
20-
rustup toolchain link "$D"_stage2 "$D/build/$target/stage2"
21-
fi
35+
rustup toolchain link "${D}_${stage}" "$directory"
36+
done
2237

2338
popd
2439
fi

0 commit comments

Comments
 (0)