-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·156 lines (133 loc) · 3.03 KB
/
build.sh
File metadata and controls
executable file
·156 lines (133 loc) · 3.03 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/bin/bash
WS=$(cd $(dirname $0);pwd)
BOLD='\033[1m'
RED='\033[0;31m'
GREEN='\033[32m'
WHITE='\033[34m'
YELLOW='\033[33m'
NO_COLOR='\033[0m'
BLUE='\033[0;34m'
function info() {
(>&2 echo -e "[${WHITE}${BOLD} INFO ${NO_COLOR}] $*")
}
function error() {
(>&2 echo -e "[${RED} ERROR ${NO_COLOR}] $*")
}
function warning() {
(>&2 echo -e "[${YELLOW} WARNING ${NO_COLOR}] $*")
}
function ok() {
(>&2 echo -e "[${GREEN}${BOLD} OK ${NO_COLOR}] $*")
}
function print_delim() {
echo '=================================================='
}
function get_now() {
echo $(date +%s)
}
function print_time() {
END_TIME=$(get_now)
ELAPSED_TIME=$(echo "$END_TIME - $START_TIME" | bc -l)
MESSAGE="Took ${ELAPSED_TIME} seconds"
info "${MESSAGE}"
}
function success() {
print_delim
ok "$1"
print_time
print_delim
}
function fail() {
print_delim
error "$1"
print_time
print_delim
}
function print_usage() {
echo -e "\n${RED}Usage${NO_COLOR}:
.${BOLD}/build.sh${NO_COLOR} [OPTION]"
echo -e "\n${RED}Options${NO_COLOR}:
${BLUE}all${NO_COLOR}: run all
${BLUE}build${NO_COLOR}: run the code build
${BLUE}clean${NO_COLOR}: clean the code build
${BLUE}cov${NO_COLOR}: run the code test coverage
${BLUE}check_code${NO_COLOR}: run the code style check
"
}
function clean() {
rm -rf build build_dist
}
function check_code() {
git clone https://github.com/FengD/code_check_tools
chmod -R +x code_check_tools
export WORKSPACE=${WS}
export CODE_CHECK_EXCLUDE_LIST="can,memory_check,communication,build_dist,build"
./code_check_tools/code_check.sh run
rm -rf code_check_tools.tar.gz code_check_tools
}
function build_make() {
MAX_CPU_NUM=$(nproc)
cd ${WS}/build
make -j$[${MAX_CPU_NUM}-1] install
if [ $? -eq 0 ]; then
success 'Build passed!'
exit 0
else
fail 'Build failed!'
exit 1
fi
}
function build() {
mkdir -p ${WS}/build && cd ${WS}/build
cmake -DWITH_COV=${WITH_COV} \
-DDO_TEST=${DO_TEST} \
${EXTRA_OPTIONS} \
-DCMAKE_INSTALL_PREFIX=${WS}/build_dist/crdc_airi_common ..
build_make
}
function main() {
local cmd=$1
cd ${WS}
if [ -z $1 ]; then
if [ ! -d "build" ]; then
cmd=all
else
cmd=build
fi
fi
shift
START_TIME=$(get_now)
BUILD_DIST=OFF
WITH_COV=OFF
DO_TEST=OFF
# get_dependencies
if [[ "${PLATFORM}" == "TDA4" ]];then
source $(find /opt/ -name environment-setup-aarch64-linux)
fi
if [ "${ARCH}" = "arm64" ]; then
EXTRA_OPTIONS="${EXTRA_OPTIONS} -DWITH_AARCH64=ON"
fi
case $cmd in
build)
build_make
;;
all)
build
;;
clean)
clean
;;
cov)
WITH_COV=ON
DO_TEST=ON
build
;;
check_code)
check_code
;;
*)
print_usage
;;
esac
}
main $@