-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·79 lines (61 loc) · 1.54 KB
/
build.sh
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
#!/bin/bash
WORKDIR=$(pwd)
DIR_DIST_TARGET=${WORKDIR}/dist-target
DIR_DIST_SIMULATOR=${WORKDIR}/dist-simulator
function do_compile_commands() {
if [ ! -f "${WORKDIR}/compile_commands.json" ]; then
echo "can't find compile_commands.json"
mkdir -p "${WORKDIR}/tmp" && pushd "${WORKDIR}/tmp"
cmake -DCROSS_COMPILE=1 .. && bear -- make -j
cp compile_commands.json "${WORKDIR}/"
popd
rm -rf tmp/
else
echo "compile_commands.json exists"
fi
}
function do_build_target() {
mkdir -p "${DIR_DIST_TARGET}" && cd "${DIR_DIST_TARGET}"
cmake -DCROSS_COMPILE=1 -G Ninja .. && ninja
cd ${WORKDIR}
ln -sf "${DIR_DIST_TARGET}/demo" ./demo
}
function do_build_simulator() {
echo "Building simulator ..."
mkdir -p "${DIR_DIST_SIMULATOR}" && cd "${DIR_DIST_SIMULATOR}"
cmake .. -G Ninja && ninja
cd ${WORKDIR}
ln -sf "${DIR_DIST_SIMULATOR}/demo" ./simulator
}
function do_usage() {
cat << "EOF" >> /dev/tty
-h print this usage
all build all things
-c build compile_commands.json
-t build for target
-s build for simulating
EOF
}
case $1 in
"-h")
exit 0
;;
"all")
do_compile_commands
do_build_target
do_build_simulator
exit 0
;;
"-c")
do_compile_commands
exit 0
;;
"-t")
do_build_target
exit 0
;;
"-s")
do_build_simulator
exit 0
esac
do_usage