-
Notifications
You must be signed in to change notification settings - Fork 8
/
cross-build.sh
executable file
·109 lines (97 loc) · 2.53 KB
/
cross-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
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
#!/bin/bash
set -e
home=/home/neuron
bdb=main
library=$home/$bdb/libs
vendor=?
arch=?
branch=?
cross=false
user=emqx
smart=false
clib=glibc
build_type=Release
while getopts ":a:v:b:c:u:s:l:d:" OPT; do
case ${OPT} in
a)
arch=$OPTARG
;;
v)
vendor=$OPTARG
;;
b)
branch=$OPTARG
;;
c)
cross=$OPTARG
;;
u)
user=$OPTARG
;;
s)
smart=$OPTARG
;;
l)
clib=$OPTARG
;;
d)
build_type=$OPTARG
;;
esac
done
case $build_type in
(Release)
neuron_dir=$home/$bdb/Program/$vendor;;
(Debug)
neuron_dir=$home/$bdb/Program_Debug/$vendor;;
esac
case $cross in
(true)
tool_dir=/usr/bin;;
(false)
tool_dir=$home/buildroot/$vendor/output/host/bin;;
esac
function compile_source_with_tag() {
local user=$1
local repo=$2
local branch=$3
cd $neuron_dir
git clone -b $branch [email protected]:${user}/${repo}.git
cd $repo
git submodule update --init
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=$build_type -DDISABLE_UT=ON \
-DTOOL_DIR=$tool_dir -DCOMPILER_PREFIX=$vendor \
-DCMAKE_SYSTEM_PROCESSOR=$arch -DLIBRARY_DIR=$library \
-DCMAKE_TOOLCHAIN_FILE=../cmake/cross.cmake
case $smart in
(true)
cmake .. -DSMART_LINK=1 -DCMAKE_BUILD_TYPE=$build_type -DDISABLE_UT=ON \
-DTOOL_DIR=$tool_dir -DCOMPILER_PREFIX=$vendor \
-DCMAKE_SYSTEM_PROCESSOR=$arch -DLIBRARY_DIR=$library \
-DCMAKE_TOOLCHAIN_FILE=../cmake/cross.cmake;;
(false)
cmake .. -DCMAKE_BUILD_TYPE=$build_type -DDISABLE_UT=ON \
-DTOOL_DIR=$tool_dir -DCOMPILER_PREFIX=$vendor \
-DCMAKE_SYSTEM_PROCESSOR=$arch -DLIBRARY_DIR=$library \
-DCMAKE_TOOLCHAIN_FILE=../cmake/cross.cmake;;
esac
case $clib in
(glibc)
;;
(*)
cmake .. -DCMAKE_BUILD_TYPE=$build_type -DDISABLE_UT=ON \
-DTOOL_DIR=$tool_dir -DCOMPILER_PREFIX=$vendor \
-DCMAKE_SYSTEM_PROCESSOR=$arch -DLIBRARY_DIR=$library \
-DCLIB=\'\"$clib\"\' \
-DCMAKE_TOOLCHAIN_FILE=../cmake/cross.cmake;;
esac
make -j4
if [ $repo == "neuron" ]; then
sudo make install
fi
}
sudo rm -rf $neuron_dir/*
mkdir -p $neuron_dir
compile_source_with_tag $user neuron $branch
compile_source_with_tag $user neuron-modules $branch