1
- #! /bin/bash
1
+ #! /bin/sh
2
+
3
+ export AUTOM4TE=" autom4te"
4
+ export AUTOCONF=" autoconf"
5
+
6
+ OS_RELEASE=0
7
+ OS_ARCH=" x86_64"
8
+ version=` cat /proc/version`
9
+ ELX_OPTION=" --with-beyondtrust=yes"
10
+
11
+ MINIDUMP_OPTION=
12
+ if [[ " $version " =~ " aarch64" ]]
13
+ then
14
+ MINIDUMP_OPTION=" --with-obproxy-minidump=no"
15
+ else
16
+ MINIDUMP_OPTION=" --with-obproxy-minidump=yes"
17
+ fi
18
+
2
19
TOPDIR=" $( dirname $( readlink -f " $0 " ) ) "
3
20
DEP_DIR=${TOPDIR} /deps/3rd/usr/local/oceanbase/deps/devel
4
21
TOOLS_DIR=${TOPDIR} /deps/3rd/usr/local/oceanbase/devtools
5
22
RUNTIME_DIR=${TOPDIR} /deps/3rd/usr
6
23
CPU_CORES=` grep -c ^processor /proc/cpuinfo`
7
24
MAKE_ARGS=" -j $CPU_CORES "
25
+ BOLT_PATH=${TOPDIR} /deps/3rd/opt/alibaba-cloud-compiler/bin
8
26
9
- PACKAGE=${2:- obproxy-ce}
10
- VERSION=${3:- `cat rpm/ ${PACKAGE} -VER.txt`}
27
+ export DEP_DIR;
28
+ export TOOLS_DIR;
29
+ export RUNTIME_DIR;
30
+
31
+ PACKAGE=${2:- obproxy}
32
+ OBPROXY_VERSION=${3:- `cat rpm/ ${PACKAGE} -ce-VER.txt`}
11
33
RELEASE=${4:- 1}
12
34
PREFIX=/home/admin/obproxy
13
35
SPEC_FILE=obproxy.spec
14
36
15
- function sw()
16
- {
17
- export DEP_DIR;
18
- export TOOLS_DIR;
19
- export RUNTIME_DIR;
20
- export DEP_VAR=$DEP_DIR /var/;
21
- /sbin/ldconfig -n $DEP_DIR /lib;
22
- export LD_LIBRARY_PATH=$DEP_DIR /lib:$DEP_VAR /usr/local/lib64:$DEP_VAR /usr/local/lib:$DEP_VAR /usr/lib64:$DEP_VAR /usr/lib:$DEP_VAR /lib64:/usr/lib/x86_64-linux-gnu;
23
- export LIBRARY_PATH=$DEP_DIR /lib:$DEP_VAR /usr/local/lib64:$DEP_VAR /usr/local/lib:$DEP_VAR /usr/lib64:$DEP_VAR /usr/lib:/usr/lib/x86_64-linux-gnu;
24
- export CPLUS_INCLUDE_PATH=$DEP_DIR /include:${RUNTIME_DIR} /include:$DEP_VAR /usr/local/include:$DEP_VAR /usr/include:$DEP_VAR /devel/include:/usr/include/x86_64-linux-gnu;
25
- export C_INCLUDE_PATH=$DEP_DIR /include:${RUNTIME_DIR} /include:/usr/include/x86_64-linux-gnu;
26
- export PATH=$DEP_DIR /bin:$TOOLS_DIR /bin:$PATH ;
37
+ source /etc/os-release || exit 1
38
+
39
+ PNAME=${PRETTY_NAME:- " ${NAME} ${VERSION} " }
40
+
41
+ function compat_centos8() {
42
+ echo " [NOTICE] '$PNAME ' is compatible with CentOS 8, use el8 dependencies list"
43
+ OS_RELEASE=8
27
44
}
28
45
29
- export AUTOM4TE=" autom4te"
30
- export AUTOCONF=" autoconf"
46
+ function compat_centos7() {
47
+ echo " [NOTICE] '$PNAME ' is compatible with CentOS 7, use el7 dependencies list"
48
+ OS_RELEASE=7
49
+ }
50
+
51
+ function not_supported() {
52
+ echo " [ERROR] '$PNAME ' is not supported yet."
53
+ }
54
+
55
+ function version_ge() {
56
+ test " $( awk -v v1=$VERSION_ID -v v2=$1 ' BEGIN{print(v1>=v2)?"1":"0"}' 2> /dev/null) " == " 1"
57
+ }
58
+
59
+ function get_os_release() {
60
+ OS_ARCH=" $( uname -m) " || exit 1
61
+ if [[ " ${OS_ARCH} x" == " x86_64x" ]]; then
62
+ case " $ID " in
63
+ alinux)
64
+ version_ge " 3" && compat_centos8 && return
65
+ version_ge " 2.1903" && compat_centos7 && return
66
+ ;;
67
+ alios)
68
+ version_ge " 8.0" && compat_centos8 && return
69
+ version_ge " 7.2" && compat_centos7 && return
70
+ ;;
71
+ anolis)
72
+ version_ge " 8.0" && compat_centos8 && return
73
+ version_ge " 7.0" && compat_centos7 && return
74
+ ;;
75
+ ubuntu)
76
+ version_ge " 16.04" && compat_centos7 && return
77
+ ;;
78
+ centos)
79
+ version_ge " 8.0" && OS_RELEASE=8 && return
80
+ version_ge " 7.0" && OS_RELEASE=7 && return
81
+ ;;
82
+ almalinux)
83
+ version_ge " 8.0" && compat_centos8 && return
84
+ ;;
85
+ debian)
86
+ version_ge " 9" && compat_centos7 && return
87
+ ;;
88
+ fedora)
89
+ version_ge " 33" && compat_centos7 && return
90
+ ;;
91
+ opensuse-leap)
92
+ version_ge " 15" && compat_centos7 && return
93
+ ;;
94
+ # suse
95
+ sles)
96
+ version_ge " 15" && compat_centos7 && return
97
+ ;;
98
+ uos)
99
+ version_ge " 20" && compat_centos7 && return
100
+ ;;
101
+ esac
102
+ elif [[ " ${OS_ARCH} x" == " aarch64x" ]]; then
103
+ case " $ID " in
104
+ alios)
105
+ version_ge " 8.0" && compat_centos8 && return
106
+ version_ge " 7.0" && compat_centos7 && return
107
+ ;;
108
+ centos)
109
+ version_ge " 8.0" && OS_RELEASE=8 && return
110
+ version_ge " 7.0" && OS_RELEASE=7 && return
111
+ ;;
112
+ esac
113
+ fi
114
+ not_supported && return 1
115
+ }
31
116
32
117
function do_init()
33
118
{
34
- set -x
35
- sw
36
- aclocal
37
- libtoolize --force --copy --automake
38
- autoconf --force
39
- automake --foreign --copy --add-missing -Woverride -Werror
119
+ set -x
120
+ aclocal
121
+ libtoolize --force --copy --automake
122
+ autoconf --force
123
+ automake --foreign --copy --add-missing -Woverride -Werror
40
124
}
41
125
42
126
function do_dep_init()
@@ -48,24 +132,31 @@ function do_dep_init()
48
132
49
133
function do_clean()
50
134
{
51
- echo ' cleaning...'
52
- make distclean > /dev/null 2>&1
53
- rm -rf autom4te.cache
54
- for fn in aclocal.m4 configure config.guess config.sub depcomp install-sh \
55
- ltmain.sh libtool missing mkinstalldirs config.log config.status Makefile; do
56
- rm -f $fn
57
- done
58
-
59
- find . -name Makefile.in -exec rm -f {} \;
60
- find . -path ./tools/codestyle/astyle/build -prune -o -path ./doc -prune -o -name Makefile -exec rm -f {} \;
61
- find . -name .deps -prune -exec rm -rf {} \;
62
- echo ' done'
135
+ echo ' cleaning...'
136
+ make distclean > /dev/null 2>&1
137
+ rm -rf autom4te.cache
138
+ for fn in aclocal.m4 configure config.guess config.sub depcomp install-sh \
139
+ ltmain.sh libtool missing mkinstalldirs config.log config.status Makefile; do
140
+ rm -f $fn
141
+ done
142
+
143
+ find . -name Makefile.in -exec rm -f {} \;
144
+ find . -path ./tools/codestyle/astyle/build -prune -o -path ./doc -prune -o -name Makefile -exec rm -f {} \;
145
+ find . -name .deps -prune -exec rm -rf {} \;
146
+ echo ' done'
63
147
}
64
148
65
149
function do_config()
66
150
{
67
151
set -x
68
- sw
152
+ get_os_release
153
+
154
+ if test ${OS_RELEASE} -eq 8 -a " ${OS_ARCH} x" = " aarch64x" ; then
155
+ sed -i " /The path to search for executables/{N;N;N;d;}" configure.ac
156
+ sed -i " /set gcc executable path/{N;N;N;d;}" configure.ac
157
+ sed -i " /set g++ executable path/{N;N;N;d;}" configure.ac
158
+ fi
159
+
69
160
case " x$1 " in
70
161
xdebug)
71
162
# configure for developers
@@ -89,8 +180,8 @@ function do_config()
89
180
;;
90
181
xerrsim)
91
182
# configure for error injection
92
- ./configure --with-gcc-version=9.3.0 --with-coverage=no --enable-buildtime=no --enable-strip-ut=no --enable-silent-rules --enable-dlink-observer=no --with-errsim=yes ${MINIDUMP_OPTION} ${ELX_OPTION}
93
- echo -e " \033[31m ===build errsim version=== \033[0m"
183
+ ./configure --with-gcc-version=9.3.0 --with-coverage=no --enable-buildtime=no --enable-strip-ut=no --enable-silent-rules --enable-dlink-observer=no --with-errsim=yes
184
+ echo -e " \033[31m ===build errsim version=== \033[0m"
94
185
;;
95
186
* )
96
187
# configure for release
@@ -103,15 +194,33 @@ function do_config()
103
194
function do_make()
104
195
{
105
196
set -x
106
- sw
107
197
make $MAKE_ARGS
108
198
}
109
199
110
- function do_rpm ()
200
+ function do_bolt ()
111
201
{
112
202
set -x
113
- sw
203
+ echo -e " [BUILD] do bolt opt"
204
+ rm -f ${TOPDIR} /src/obproxy/obproxy.origin
205
+ cp ${TOPDIR} /src/obproxy/obproxy ${TOPDIR} /src/obproxy/obproxy.origin
206
+ ${BOLT_PATH} /llvm-bolt ${TOPDIR} /src/obproxy/obproxy.origin \
207
+ -o ${TOPDIR} /src/obproxy/obproxy \
208
+ -data=${TOPDIR} /bolt/perf.bolt.fdata.point_select \
209
+ -data2=${TOPDIR} /bolt/perf.bolt.fdata.read_write \
210
+ -reorder-blocks=ext-tsp \
211
+ -reorder-functions=hfsort+ \
212
+ -split-functions=3 \
213
+ -split-all-cold \
214
+ -dyno-stats \
215
+ --use-gnu-stack \
216
+ --update-debug-sections \
217
+ --bolt-info=false \
218
+ -v=0
219
+ }
114
220
221
+ function do_rpm()
222
+ {
223
+ set -x
115
224
echo " [BUILD] make dist..."
116
225
make dist-gzip || exit 1
117
226
@@ -122,11 +231,11 @@ function do_rpm()
122
231
mkdir -p ${TMP_DIR} /RPMS
123
232
mkdir -p ${TMP_DIR} /SOURCES
124
233
mkdir -p ${TMP_DIR} /SRPMS
125
- cp ${PACKAGE} -${VERSION } .tar.gz ${TMP_DIR} /SOURCES
234
+ cp ${PACKAGE} -${OBPROXY_VERSION } .tar.gz ${TMP_DIR} /SOURCES
126
235
cd ${TMP_DIR} /BUILD
127
236
128
237
echo " [BUILD] make rpms..._prefix=${PREFIX} spec_file=${SPEC_FILE} "
129
- rpmbuild --define " _topdir ${TMP_DIR} " --define " NAME ${PACKAGE} " --define " VERSION ${VERSION } " --define " _prefix ${PREFIX} " --define " RELEASE ${RELEASE} " --define " rpm_path ${TOPDIR} " -ba ${TOPDIR} /deps/3rd/${SPEC_FILE} || exit 2
238
+ rpmbuild --define " _topdir ${TMP_DIR} " --define " NAME ${PACKAGE} " --define " VERSION ${OBPROXY_VERSION } " --define " _prefix ${PREFIX} " --define " RELEASE ${RELEASE} " --define " rpm_path ${TOPDIR} " -ba ${TOPDIR} /deps/3rd/${SPEC_FILE} || exit 2
130
239
echo " [BUILD] make rpms done."
131
240
132
241
cd ${TOPDIR}
@@ -155,9 +264,14 @@ xrpm)
155
264
do_config
156
265
do_rpm
157
266
;;
267
+ xbolt)
268
+ # need `do_config release`
269
+ do_bolt
270
+ ;;
158
271
* )
159
272
do_dep_init
160
273
do_config
161
274
do_make
162
- ;;
275
+ do_bolt
276
+ ;;
163
277
esac
0 commit comments