-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepare_rust.sh
executable file
·71 lines (65 loc) · 1.41 KB
/
prepare_rust.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
set -o xtrace
usage()
{
echo "Prepares a rust installation suitable for kernel compilation"
echo "Usage:"
echo " $(basename $0) [Options] [<Command> ...]"
echo "Options:"
echo " -h : Print usage information"
echo " -n : Dry-run print commands instead of executing them"
echo " -x : Enabling tracing of shell script"
echo " -q : Disable tracing of shell script"
echo
}
CMD="/bin/bash"
while getopts 'hnxq' argv
do
case $argv in
h)
usage
exit 0
;;
n)
echo "Dry-Run"
DR=echo
;;
q)
echo "Disable tracing"
set +x
CMD="/bin/bash"
;;
x)
echo "Enabling tracing"
set -x
CMD="/bin/bash -x"
;;
esac
done
# Obscure option syntax: A + to turn off a "no" option...
set +o nounset
if [ -n "$DR" ]; then
DO_CMD="cat"
else
DO_CMD="$CMD"
fi
$DR cd "$(dirname "$0")"
unset LC_CTYPE
unset LANG
$DO_CMD <<EOF
mkdir -p "$(pwd)/build"
export CARGO_HOME="$(pwd)/build/cargo"
export RUSTUP_HOME="$(pwd)/build/rust"
rm -rf ${CARGO_HOME} ${RUSTUP_HOME}
curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path --default-toolchain none
source "$(pwd)/build/cargo/env"
rustup override set 1.71.1
rustup default 1.71.1
rustup component add rust-src
cargo install --locked --version 0.65.1 bindgen-cli
rustup component add rustfmt
rustup component add clippy
EOF