forked from dragon-tc/build
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_dtc
executable file
·99 lines (88 loc) · 2.32 KB
/
build_dtc
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
export DTC_USE_LLD="OFF";
export DTC_USE_THINLTO="OFF";
# Enable ccache if requested
if ! [ -z "$DTC_USE_CCACHE" ];
then
export DTC_CCACHE=ON;
else
export DTC_CCACHE=OFF;
fi;
show_help() {
echo "Usage: `basename $0` [9.0/10.0] [opt] [lld/thinlto]"
echo ""
echo "Example: `basename $0` 10.0 opt thinlto"
echo "Example2: `basename $0` 10.0 lld"
echo ""
echo "Commands:"
echo "-h Show this menu."
echo ""
echo "--help Also shows this menu."
echo ""
echo "opt Builds using -march=native -mtune=native."
echo " Building with this makes it for your system only."
echo ""
echo "lld Builds using lld as the linker. This enables clang as host toolchain."
echo ""
echo "thinlto Enables thinlto during the build. This enables clang as host toolchain."
echo " It also enables lld as the linker and increases build time."
echo ""
echo "To enable ccache export DTC_USE_CCACHE=1 before running the script."
echo ""
exit 0
}
setup_dtc_build() {
# Find source root
export TOOLCHAIN_ROOT="$(dirname "$(pwd)")"
# Set remote url and sync
export REMOTE_URL="https://github.com/dragon-tc-tmp"
$TOOLCHAIN_ROOT/build/bin/common sync;
# Clean tree
if [ -d $TOOLCHAIN_ROOT/cmake ];
then
$TOOLCHAIN_ROOT/build/bin/common clean;
fi;
# Compile DragonTC LLVM/Clang
$TOOLCHAIN_ROOT/build/bin/common build;
}
# Detect version and setup
if [ "$1" == "9.0" ]; then
export BRANCH="release_90"
export DTC_VERSION="9.0";
export DTC_LIB_VERSION="9.0.0";
elif [ "$1" == "10.0" ]; then
export BRANCH="release_100"
export DTC_VERSION="10.0";
export DTC_LIB_VERSION="10.0.0";
elif [ "$1" == "-h" ]; then
show_help
elif [ "$1" == "--help" ]; then
show_help
else
show_help
fi
# Setup build options
if [ "$2" == "opt" ]; then
export OPT="-march=native -mtune=native";
elif [ "$2" == "lld" ]; then
export CC="clang";
export CXX="clang++";
export DTC_USE_LLD="ON";
elif [ "$2" == "thinlto" ]; then
export CC="clang";
export CXX="clang++";
export DTC_USE_LLD="ON";
export DTC_USE_THINLTO="Thin";
fi;
if [ "$3" == "lld" ]; then
export CC="clang";
export CXX="clang++";
export DTC_USE_LLD="ON";
elif [ "$3" == "thinlto" ]; then
export CC="clang";
export CXX="clang++";
export DTC_USE_LLD="ON";
export DTC_USE_THINLTO="Thin";
fi;
# Setup and build
setup_dtc_build