Skip to content

Commit d556c56

Browse files
committed
Add option to build using the sysroot of rustc
1 parent 17cffc1 commit d556c56

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

build.sh

+26-11
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ set -e
33

44
# Settings
55
export CHANNEL="release"
6-
build_sysroot=1
6+
build_sysroot="clif"
77
target_dir='build'
88
oldbe=''
99
while [[ $# != 0 ]]; do
1010
case $1 in
1111
"--debug")
1212
export CHANNEL="debug"
1313
;;
14-
"--without-sysroot")
15-
build_sysroot=0
14+
"--sysroot")
15+
build_sysroot=$2
16+
shift
1617
;;
1718
"--target-dir")
1819
target_dir=$2
@@ -23,7 +24,7 @@ while [[ $# != 0 ]]; do
2324
;;
2425
*)
2526
echo "Unknown flag '$1'"
26-
echo "Usage: ./build.sh [--debug] [--without-sysroot] [--target-dir DIR] [--oldbe]"
27+
echo "Usage: ./build.sh [--debug] [--sysroot none|clif|llvm] [--target-dir DIR] [--oldbe]"
2728
exit 1
2829
;;
2930
esac
@@ -62,10 +63,24 @@ if [[ "$TARGET_TRIPLE" == "x86_64-pc-windows-gnu" ]]; then
6263
cp $(rustc --print sysroot)/lib/rustlib/$TARGET_TRIPLE/lib/*.o "$target_dir/lib/rustlib/$TARGET_TRIPLE/lib/"
6364
fi
6465

65-
if [[ "$build_sysroot" == "1" ]]; then
66-
echo "[BUILD] sysroot"
67-
dir=$(pwd)
68-
cd "$target_dir"
69-
time "$dir/build_sysroot/build_sysroot.sh"
70-
cp lib/rustlib/*/lib/libstd-* lib/
71-
fi
66+
case "$build_sysroot" in
67+
"none")
68+
;;
69+
"llvm")
70+
cp -r $(rustc --print sysroot)/lib/rustlib/$TARGET_TRIPLE/lib "$target_dir/lib/rustlib/$TARGET_TRIPLE/"
71+
;;
72+
"clif")
73+
echo "[BUILD] sysroot"
74+
dir=$(pwd)
75+
cd "$target_dir"
76+
time "$dir/build_sysroot/build_sysroot.sh"
77+
cp lib/rustlib/*/lib/libstd-* lib/
78+
;;
79+
*)
80+
echo "Unknown sysroot kind \`$build_sysroot\`."
81+
echo "The allowed values are:"
82+
echo " none A sysroot that doesn't contain the standard library"
83+
echo " llvm Copy the sysroot from rustc compiled by cg_llvm"
84+
echo " clif Build a new sysroot using cg_clif"
85+
exit 1
86+
esac

test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -e
33

4-
./build.sh --without-sysroot "$@"
4+
./build.sh --sysroot none "$@"
55

66
rm -r target/out || true
77

0 commit comments

Comments
 (0)