-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·126 lines (110 loc) · 2.86 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
#
# Script for Dev's daily work. It is a good idea to use the exact same
# build options as the released version.
get_key_value()
{
echo "$1" | sed 's/^--[a-zA-Z_-]*=//'
}
usage()
{
cat <<EOF
Usage: $0 [-t debug|release] [-d <dest_dir>] [-s <server_suffix>]
Or
$0 [-h | --help]
-t Select the build type.
-d Set the destination directory.
-s Set the server suffix.
-h, --help Show this help message.
Note: this script is intended for internal use by MySQL developers.
EOF
}
parse_options()
{
while test $# -gt 0
do
case "$1" in
-t=*)
build_type=`get_key_value "$1"`;;
-t)
shift
build_type=`get_key_value "$1"`;;
-d=*)
dest_dir=`get_key_value "$1"`;;
-d)
shift
dest_dir=`get_key_value "$1"`;;
-s=*)
server_suffix=`get_key_value "$1"`;;
-s)
shift
server_suffix=`get_key_value "$1"`;;
-h | --help)
usage
exit 0;;
*)
echo "Unknown option '$1'"
exit 1;;
esac
shift
done
}
dump_options()
{
echo "Dumping the options used by $0 ..."
echo "build_type=$build_type"
echo "dest_dir=$dest_dir"
echo "server_suffix=$server_suffix"
}
if test ! -f sql/mysqld.cc
then
echo "You must run this script from the MySQL top-level directory"
exit 1
fi
build_type="debug"
dest_dir=$HOME/tmp_run2
server_suffix="rds-dev"
parse_options "$@"
dump_options
if [ x"$build_type" = x"debug" ]; then
build_type="Debug"
debug=1
debug_sync=1
elif [ x"$build_type" = x"release" ]; then
# Release CMAKE_BUILD_TYPE is not compatible with mysql 8.0
# build_type="Release"
build_type="RelWithDebInfo"
debug=0
debug_sync=0
else
echo "Invalid build type, it must be \"debug\" or \"release\"."
exit 1
fi
server_suffix="-""$server_suffix"
if [ x"$build_type" = x"RelWithDebInfo" ]; then
COMMON_FLAGS="-O3 -g -fexceptions -static-libgcc -static-libstdc++ -fno-omit-frame-pointer -fno-strict-aliasing"
CFLAGS="$COMMON_FLAGS"
CXXFLAGS="$COMMON_FLAGS"
elif [ x"$build_type" = x"Debug" ]; then
COMMON_FLAGS="-O0 -g3 -fexceptions -fno-omit-frame-pointer -fstack-protector-strong"
CFLAGS="$COMMON_FLAGS"
CXXFLAGS="$COMMON_FLAGS"
fi
CC=gcc
CXX=g++
export CC CFLAGS CXX CXXFLAGS
rm -rf CMakeCache.txt
make clean
cat extra/boost/boost_1_77_0.tar.bz2.* > extra/boost/boost_1_77_0.tar.bz2
cmake . \
-DCMAKE_BUILD_TYPE="$build_type" \
-DCMAKE_INSTALL_PREFIX="$dest_dir" \
-DCMAKE_COMPILE_COMMANDS=1 \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DBUILD_CONFIG=xtrabackup_release \
-DWITH_DEBUG=$debug \
-DFORCE_INSOURCE_BUILD=1 \
-DWITH_BOOST="./extra/boost/boost_1_77_0.tar.bz2" \
-DMYSQL_SERVER_SUFFIX="$server_suffix"
make -j $(nproc) install
# end of file