]> git.lizzy.rs Git - rust.git/blob - build.sh
Better build dir layout
[rust.git] / build.sh
1 #!/bin/bash
2 set -e
3
4 # Settings
5 export CHANNEL="release"
6 build_sysroot=1
7 target_dir='build'
8 while [[ $# != 0 ]]; do
9     case $1 in
10         "--debug")
11             export CHANNEL="debug"
12             ;;
13         "--without-sysroot")
14             build_sysroot=0
15             ;;
16         "--target-dir")
17             target_dir=$2
18             shift
19             ;;
20         *)
21             echo "Unknown flag '$1'"
22             echo "Usage: ./build.sh [--debug] [--without-sysroot] [--target-dir DIR]"
23             ;;
24     esac
25     shift
26 done
27
28 # Build cg_clif
29 unset CARGO_TARGET_DIR
30 export RUSTFLAGS="-Zrun_dsymutil=no"
31 if [[ "$CHANNEL" == "release" ]]; then
32     cargo build --release
33 else
34     cargo build
35 fi
36
37 rm -rf "$target_dir"
38 mkdir "$target_dir"
39 mkdir "$target_dir"/bin "$target_dir"/lib
40 cp -a target/$CHANNEL/cg_clif{,_build_sysroot} "$target_dir"/bin
41 cp -a target/$CHANNEL/*rustc_codegen_cranelift* "$target_dir"/lib
42 cp -a rust-toolchain scripts/config.sh scripts/cargo.sh "$target_dir"
43
44 if [[ "$build_sysroot" == "1" ]]; then
45     echo "[BUILD] sysroot"
46     export CG_CLIF_INCR_CACHE_DISABLED=1
47     dir=$(pwd)
48     cd "$target_dir"
49     time "$dir/build_sysroot/build_sysroot.sh"
50 fi