This repository has been archived by the owner on Oct 17, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
install-libcore.sh
72 lines (62 loc) · 1.48 KB
/
install-libcore.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
72
#!/bin/bash
# Exit if anything fails
set -e
DIR=$( pwd )
usage="Usage: sh $0 your-target-name [disable_float]"
if [[ "$#" -lt 1 || "$#" -gt 2 ]]; then
echo $usage >&2
exit 1
fi
if [[ "$1" == "-h" || "$1" == "help" || "$1" == "-help" || "$1" == "--help" ]]; then
echo $usage >&2
exit 0
fi
target="$1"
if [ "$#" -eq 2 ]; then
if [[ "$2" == "disable_float" ]]; then
features="--features disable_float"
else
echo $usage >&2
exit 1
fi
else
features=""
fi
extension="${target##*.}"
if [[ extension == "json" ]]; then
targetWithExtension="$target"
else
targetWithExtension="$target.json"
fi
if multirust which rustc > /dev/null; then
rustcDir=$( multirust which rustc )
elif which rustc > /dev/null; then
rustcDir=$( which rustc )
else
echo "Could not detect rust installation!" >&2
exit 1
fi
libraries=$( echo "$rustcDir" | sed s,"bin/rustc","lib/rustlib/$target/lib", )
echo "Installing libcore for $target to"
echo "$libraries"
echo ""
git clone --depth 1 https://github.com/phil-opp/nightly-libcore.git
if [ -f "$targetWithExtension" ]; then
cp "$targetWithExtension" "nightly-libcore/$targetWithExtension"
fi
cd nightly-libcore
echo ""
if cargo build --release $features --target=$target --verbose; then
echo ""
mkdir -p "$libraries"
cp "target/$target/release/libcore.rlib" "$libraries/"
cd ..
rm -rf nightly-libcore
echo "done, removing the installation script"
rm "$0"
else
echo "Cargo build failed!" >&2
cd ..
rm -rf nightly-libcore
exit 1
fi