Skip to content

Commit

Permalink
Add option to build using the sysroot of rustc
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Jan 31, 2021
1 parent 17cffc1 commit d556c56
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
37 changes: 26 additions & 11 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ set -e

# Settings
export CHANNEL="release"
build_sysroot=1
build_sysroot="clif"
target_dir='build'
oldbe=''
while [[ $# != 0 ]]; do
case $1 in
"--debug")
export CHANNEL="debug"
;;
"--without-sysroot")
build_sysroot=0
"--sysroot")
build_sysroot=$2
shift
;;
"--target-dir")
target_dir=$2
Expand All @@ -23,7 +24,7 @@ while [[ $# != 0 ]]; do
;;
*)
echo "Unknown flag '$1'"
echo "Usage: ./build.sh [--debug] [--without-sysroot] [--target-dir DIR] [--oldbe]"
echo "Usage: ./build.sh [--debug] [--sysroot none|clif|llvm] [--target-dir DIR] [--oldbe]"
exit 1
;;
esac
Expand Down Expand Up @@ -62,10 +63,24 @@ if [[ "$TARGET_TRIPLE" == "x86_64-pc-windows-gnu" ]]; then
cp $(rustc --print sysroot)/lib/rustlib/$TARGET_TRIPLE/lib/*.o "$target_dir/lib/rustlib/$TARGET_TRIPLE/lib/"
fi

if [[ "$build_sysroot" == "1" ]]; then
echo "[BUILD] sysroot"
dir=$(pwd)
cd "$target_dir"
time "$dir/build_sysroot/build_sysroot.sh"
cp lib/rustlib/*/lib/libstd-* lib/
fi
case "$build_sysroot" in
"none")
;;
"llvm")
cp -r $(rustc --print sysroot)/lib/rustlib/$TARGET_TRIPLE/lib "$target_dir/lib/rustlib/$TARGET_TRIPLE/"
;;
"clif")
echo "[BUILD] sysroot"
dir=$(pwd)
cd "$target_dir"
time "$dir/build_sysroot/build_sysroot.sh"
cp lib/rustlib/*/lib/libstd-* lib/
;;
*)
echo "Unknown sysroot kind \`$build_sysroot\`."
echo "The allowed values are:"
echo " none A sysroot that doesn't contain the standard library"
echo " llvm Copy the sysroot from rustc compiled by cg_llvm"
echo " clif Build a new sysroot using cg_clif"
exit 1
esac
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

./build.sh --without-sysroot "$@"
./build.sh --sysroot none "$@"

rm -r target/out || true

Expand Down

0 comments on commit d556c56

Please sign in to comment.