forked from Yarkin/TOP-chain
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·83 lines (69 loc) · 1.97 KB
/
build.sh
File metadata and controls
executable file
·83 lines (69 loc) · 1.97 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
#!/bin/sh
function command_line_option_include_item {
local list="$1"
local value="$2"
local result=1
for item in $list
do
if [ $item = $value ]; then
# found
result=0
fi;
done
return $result
}
osname=`uname` # Linux/Darwin
echo "osname: $osname"
options="$@"
command_line_option_include_item "$options" "pack"
if [ $? -eq 0 ]; then
# make install package
pack_mode="debug"
command_line_option_include_item "$options" "release"
if [ $? -eq 0 ]; then
pack_mode="release"
fi
sh ./pack.sh "$pack_mode"
exit 0
fi
command_line_option_include_item "$options" "install"
if [ $? -eq 1 ]; then
echo "no install found, compile mode"
CMAKE_EXTRA_OPTIONS="-DCMAKE_BUILD_TYPE=Debug -DXENABLE_TESTS=OFF"
CBUILD_DIR="cbuild"
source ./build_options.sh
command_line_option_include_item "$options" "leak_trace"
if [ $? -eq 0 ]; then
CBUILD_DIR="${CBUILD_DIR}_leak"
fi
echo "CMAKE_EXTRA_OPTIONS: ${CMAKE_EXTRA_OPTIONS}"
echo "CBUILD_DIR: ${CBUILD_DIR}"
mkdir -p ${CBUILD_DIR}
cd ${CBUILD_DIR}
if [ $osname == "Linux" ]; then
cmake3 .. ${CMAKE_EXTRA_OPTIONS}
CPU_CORE=$( lscpu -pCPU | grep -v "#" | wc -l )
elif [ $osname == "Darwin" ]; then
cmake .. ${CMAKE_EXTRA_OPTIONS}
CPU_CORE=$( sysctl hw|grep ncpu|awk -F ':' '{print $2}' )
fi
# # MEM_MEG=$( free -m | sed -n 2p | tr -s ' ' | cut -d\ -f2 )
# # MEM_GIG=$(( ((MEM_MEG / 1000) / 2) ))
# # JOBS=$(( MEM_GIG > CPU_CORE ? CPU_CORE : MEM_GIG ))
# # make -j${JOBS}
if [ $CPU_CORE -le 4 ]; then
make -j4
else
make -j${CPU_CORE}
fi
else
cbuild_path="cbuild"
command_line_option_include_item "$options" "release"
if [ $? -eq 0 ]; then
cbuild_path="cbuild_release"
fi
echo "install found, install mode from path:$cbuild_path"
cd $cbuild_path
make install
sudo ldconfig
fi