-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
108 lines (90 loc) · 2.22 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
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
#cmake - DCMAKE_BUILD_TYPE = Release - B./ build && cmake-- build build - j4-- config Release
function build_loong()
{
#clang - format - style = file - i controllers/*
#Update the submodule and initialize
#git submodule update --init
#Save current directory
current_dir="${PWD}"
#The folder in which we will build
build_dir='./build'
if [ -d $build_dir ]; then
echo "Deleted folder: ${build_dir}"
rm -rf $build_dir
fi
#Create building folder
echo "Created building folder: ${build_dir}"
mkdir $build_dir
echo "Entering folder: ${build_dir}"
cd $build_dir || exit
echo "Start building ..."
if [ $1 -eq 1 ]; then
cmake .. -DCMAKE_BUILD_TYPE=Debug $cmake_gen
elif [ $1 -eq 2 ]; then
cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_DROGON_SHARED=ON -DCMAKE_CXX_VISIBILITY_PRESET=hidden -DCMAKE_VISIBILITY_INLINES_HIDDEN=1 $cmake_gen
else
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=g++-14 $cmake_gen
fi
#If errors then exit
# shellcheck disable=SC2181
if [ "$?" != "0" ]; then
# shellcheck disable=SC2242
exit -1
fi
$make_program $make_flags
#If errors then exit
# shellcheck disable=SC2181
if [ "$?" != "0" ]; then
# shellcheck disable=SC2242
exit -1
fi
#echo "Installing ..."
#sudo $make_program install
#Go back to the current directory
cd $current_dir || exit
echo "Starting ..."
$build_dir/loong-boot
#Ok!
}
# shellcheck disable=SC2209
make_program=make
make_flags=''
cmake_gen=''
parallel=1
case $(uname) in
FreeBSD)
nproc=$(sysctl -n hw.ncpu)
;;
Darwin)
nproc=$(sysctl -n hw.ncpu) # sysctl -n hw.ncpu is the equivalent to nproc on macOS.
;;
*)
nproc=$(nproc)
;;
esac
# simulate ninja's parallelism
# shellcheck disable=SC2194
case nproc in
1)
parallel=$(( nproc + 1 ))
;;
2)
parallel=$(( nproc + 1 ))
;;
*)
parallel=$(( nproc + 2 ))
;;
esac
if [ -f /bin/ninja ]; then
make_program=ninja
cmake_gen='-GNinja'
else
make_flags="$make_flags -j$parallel"
fi
if [ "$1" = "-t" ]; then
build_loong 1
elif [ "$1" = "-tshared" ]; then
build_loong 2
else
build_loong 0
fi